conveyor 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/History.txt +4 -0
- data/Rakefile +1 -4
- data/bin/conveyor +1 -1
- data/docs/protocol.mkd +1 -1
- data/lib/conveyor.rb +1 -1
- data/lib/conveyor/channel.rb +13 -1
- data/lib/conveyor/server.rb +5 -0
- data/test/test_channel.rb +20 -0
- data/test/test_server.rb +29 -0
- metadata +15 -6
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -8,12 +8,9 @@ Hoe.new('conveyor', Conveyor::VERSION) do |p|
|
|
8
8
|
p.rubyforge_name = 'conveyor'
|
9
9
|
p.author = 'Ryan King'
|
10
10
|
p.email = 'ryan@theryanking.com'
|
11
|
-
p.summary = 'Like TiVo for your data.'
|
12
|
-
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
13
|
-
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
14
|
-
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
15
11
|
p.extra_deps << ['mongrel']
|
16
12
|
p.extra_deps << ['activesupport']
|
13
|
+
p.extra_deps << ['json']
|
17
14
|
end
|
18
15
|
|
19
16
|
# vim: syntax=Ruby
|
data/bin/conveyor
CHANGED
data/docs/protocol.mkd
CHANGED
data/lib/conveyor.rb
CHANGED
data/lib/conveyor/channel.rb
CHANGED
@@ -7,7 +7,7 @@ module Conveyor
|
|
7
7
|
class Channel < BaseChannel
|
8
8
|
|
9
9
|
# If +directory+ doesn't already exist, it will be created during initialization.
|
10
|
-
def initialize directory
|
10
|
+
def initialize directory
|
11
11
|
@group_iterators = {}
|
12
12
|
@group_iterators_files = {}
|
13
13
|
|
@@ -67,6 +67,18 @@ module Conveyor
|
|
67
67
|
r
|
68
68
|
end
|
69
69
|
|
70
|
+
def status
|
71
|
+
{
|
72
|
+
:directory => @directory,
|
73
|
+
:index => {
|
74
|
+
:size => @index.length
|
75
|
+
},
|
76
|
+
:data_files => @data_files.collect{|f| {:path => f.path, :bytes => File.size(f.path)}},
|
77
|
+
:iterator => {:position => @iterator},
|
78
|
+
:iterator_groups => @group_iterators.inject({}){|k,v, m| m[k] = v; m}
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
70
82
|
private
|
71
83
|
|
72
84
|
def group_iterators_file group
|
data/lib/conveyor/server.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'mongrel'
|
3
3
|
require 'conveyor/channel'
|
4
4
|
require 'fileutils'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
class Mongrel::HttpRequest
|
7
8
|
def put?
|
@@ -84,6 +85,10 @@ module Conveyor
|
|
84
85
|
else
|
85
86
|
headers, content = @channels[m.captures[0]].get_next
|
86
87
|
end
|
88
|
+
else
|
89
|
+
response.start(200) do |head, out|
|
90
|
+
out.write @channels[m.captures[0]].status.to_json
|
91
|
+
end
|
87
92
|
end
|
88
93
|
end
|
89
94
|
else
|
data/test/test_channel.rb
CHANGED
@@ -123,4 +123,24 @@ class TestConveyorChannel < Test::Unit::TestCase
|
|
123
123
|
assert_equal 'bam', c.get_next_by_group('bar')[1]
|
124
124
|
assert_equal nil, c.get_next_by_group('bar')
|
125
125
|
end
|
126
|
+
|
127
|
+
def test_channel_status
|
128
|
+
FileUtils.rm_r('/tmp/bar') rescue nil
|
129
|
+
c = Channel.new('/tmp/bar')
|
130
|
+
c.post 'foo'
|
131
|
+
c.post 'bar'
|
132
|
+
c.post 'bam'
|
133
|
+
|
134
|
+
status = {
|
135
|
+
:directory => '/tmp/bar',
|
136
|
+
:index => {:size => 3},
|
137
|
+
:data_files => [
|
138
|
+
{:path => '/tmp/bar/0', :bytes => 210}
|
139
|
+
],
|
140
|
+
:iterator => {:position => 0},
|
141
|
+
:iterator_groups => {}
|
142
|
+
}
|
143
|
+
|
144
|
+
assert_equal(status, c.status)
|
145
|
+
end
|
126
146
|
end
|
data/test/test_server.rb
CHANGED
@@ -90,4 +90,33 @@ class TestConveyorServer < Test::Unit::TestCase
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
def test_status
|
95
|
+
Net::HTTP.start('localhost', 8888) do |h|
|
96
|
+
req = h.put('/channels/bar', '', {'Content-Type' => 'application/octet-stream'})
|
97
|
+
assert_equal Net::HTTPCreated, req.class
|
98
|
+
|
99
|
+
data =
|
100
|
+
["ZqZyDN2SouQCYEHYS0LuM1XeqsF0MKIbFEBE6xQ972VqEcjs21wJSosvZMWEH1lq5ukTq4Ze"]
|
101
|
+
|
102
|
+
data.each do |d|
|
103
|
+
req = h.post('/channels/bar', d, {'Content-Type' => 'application/octet-stream', 'Date' => Time.now.to_s})
|
104
|
+
assert_equal Net::HTTPAccepted, req.class
|
105
|
+
end
|
106
|
+
|
107
|
+
req = h.get("/channels/bar")
|
108
|
+
assert_kind_of Net::HTTPOK, req
|
109
|
+
json = {
|
110
|
+
"iterator_groups" => {},
|
111
|
+
"index"=>{"size"=>1},
|
112
|
+
"directory"=>"/tmp/asdf/bar",
|
113
|
+
"data_files"=>[{"path"=>"/tmp/asdf/bar/0","bytes"=>139}],
|
114
|
+
"iterator"=>{"position"=>0}
|
115
|
+
}
|
116
|
+
assert_equal json, JSON::parse(req.body)
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
end
|
93
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conveyor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan King
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
Zls3y84CmyAEGg==
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2008-01-
|
33
|
+
date: 2008-01-31 00:00:00 -08:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -51,6 +51,15 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: "0"
|
53
53
|
version:
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: json
|
56
|
+
version_requirement:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
54
63
|
- !ruby/object:Gem::Dependency
|
55
64
|
name: hoe
|
56
65
|
version_requirement:
|
@@ -58,9 +67,9 @@ dependencies:
|
|
58
67
|
requirements:
|
59
68
|
- - ">="
|
60
69
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
70
|
+
version: 1.5.0
|
62
71
|
version:
|
63
|
-
description:
|
72
|
+
description: "* Like TiVo for your data * A distributed rewindable multi-queue"
|
64
73
|
email: ryan@theryanking.com
|
65
74
|
executables:
|
66
75
|
- conveyor
|
@@ -91,7 +100,7 @@ files:
|
|
91
100
|
- test/test_replicated_channel.rb
|
92
101
|
- test/test_server.rb
|
93
102
|
has_rdoc: true
|
94
|
-
homepage:
|
103
|
+
homepage: by Ryan King (http://theryanking.com)
|
95
104
|
post_install_message:
|
96
105
|
rdoc_options:
|
97
106
|
- --main
|
@@ -116,7 +125,7 @@ rubyforge_project: conveyor
|
|
116
125
|
rubygems_version: 1.0.1
|
117
126
|
signing_key:
|
118
127
|
specification_version: 2
|
119
|
-
summary: Like TiVo for your data
|
128
|
+
summary: "* Like TiVo for your data * A distributed rewindable multi-queue"
|
120
129
|
test_files:
|
121
130
|
- test/test_channel.rb
|
122
131
|
- test/test_feeder-ng.rb
|
metadata.gz.sig
CHANGED
Binary file
|