cloudist 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -6
- data/Gemfile.lock +29 -27
- data/VERSION +1 -1
- data/cloudist.gemspec +9 -21
- data/examples/sandwich_client_with_custom_listener.rb +19 -16
- data/lib/cloudist/application.rb +10 -10
- data/lib/cloudist/core_ext/class.rb +4 -4
- data/lib/cloudist/job.rb +18 -18
- data/lib/cloudist/listener.rb +32 -32
- data/lib/cloudist/message.rb +23 -23
- data/lib/cloudist/messaging.rb +9 -9
- data/lib/cloudist/payload.rb +22 -22
- data/lib/cloudist/payload_old.rb +33 -33
- data/lib/cloudist/publisher.rb +6 -6
- data/lib/cloudist/queues/basic_queue.rb +17 -17
- data/lib/cloudist/queues/job_queue.rb +6 -6
- data/lib/cloudist/queues/reply_queue.rb +5 -5
- data/lib/cloudist/request.rb +5 -5
- data/lib/cloudist/utils.rb +5 -5
- data/lib/cloudist/worker.rb +10 -10
- data/spec/cloudist/basic_queue_spec.rb +10 -10
- data/spec/cloudist/job_spec.rb +4 -4
- data/spec/cloudist/payload_spec_2_spec.rb +16 -16
- data/spec/cloudist/request_spec.rb +13 -13
- data/spec/cloudist/utils_spec.rb +3 -3
- data/spec/cloudist_spec.rb +11 -11
- data/spec/core_ext/string_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -2
- data/spec/support/amqp.rb +11 -11
- metadata +29 -73
@@ -3,39 +3,39 @@ require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
|
|
3
3
|
describe Cloudist::Request do
|
4
4
|
before {
|
5
5
|
@mq_header = mock("MQ::Header")
|
6
|
-
@mq_header.
|
7
|
-
|
6
|
+
@mq_header.stub(:headers).and_return({:published_on=>Time.now.to_i - 60, :event_hash=>"foo", :message_id=>"foo", :ttl=>300})
|
7
|
+
|
8
8
|
q = Cloudist::JobQueue.new('test.queue')
|
9
|
-
|
9
|
+
|
10
10
|
@request = Cloudist::Request.new(q, Marshal.dump({:bread => 'white'}), @mq_header)
|
11
11
|
}
|
12
|
-
|
12
|
+
|
13
13
|
it "should return ttl" do
|
14
14
|
@request.ttl.should == 300
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should have a payload" do
|
18
18
|
@request.payload.should_not be_nil
|
19
19
|
@request.payload.should be_a(Cloudist::Payload)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should be 1 minute old" do
|
23
23
|
@request.age.should == 60
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
it "should not be expired" do
|
27
27
|
@request.expired?.should_not be_true
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it "should not be acked yet" do
|
31
31
|
@request.acked?.should be_false
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
it "should be ackable" do
|
35
|
-
@mq_header.
|
36
|
-
|
35
|
+
@mq_header.stub(:ack).and_return(true)
|
36
|
+
|
37
37
|
@request.ack.should be_true
|
38
38
|
@request.acked?.should be_true
|
39
39
|
end
|
40
|
-
|
41
|
-
end
|
40
|
+
|
41
|
+
end
|
data/spec/cloudist/utils_spec.rb
CHANGED
@@ -4,15 +4,15 @@ describe Cloudist::Utils do
|
|
4
4
|
it "should return reply queue name" do
|
5
5
|
Cloudist::Utils.reply_prefix('eat.sandwich').should == 'temp.reply.eat.sandwich'
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should return log queue name" do
|
9
9
|
Cloudist::Utils.log_prefix('eat.sandwich').should == 'temp.log.eat.sandwich'
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
it "should return stats queue name" do
|
13
13
|
Cloudist::Utils.stats_prefix('eat.sandwich').should == 'temp.stats.eat.sandwich'
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# it "should generate queue name" do
|
17
17
|
# Cloudist::Utils.generate_queue('test').should == ''
|
18
18
|
# end
|
data/spec/cloudist_spec.rb
CHANGED
@@ -6,47 +6,47 @@ describe "Cloudist" do
|
|
6
6
|
stub_amqp!
|
7
7
|
end
|
8
8
|
it "should start an AMQP instance" do
|
9
|
-
AMQP.
|
10
|
-
|
9
|
+
AMQP.should_receive(:start).once
|
10
|
+
|
11
11
|
Cloudist.start do
|
12
|
-
|
12
|
+
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# before(:each) do
|
17
17
|
# overload_amqp
|
18
18
|
# reset_broker
|
19
19
|
# Cloudist.remove_workers
|
20
|
-
#
|
20
|
+
#
|
21
21
|
# @mq = mock("MQ")
|
22
22
|
# @queue, @exchange = mock_queue_and_exchange('make.sandwich')
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# @qobj = Cloudist::JobQueue.any_instance
|
25
25
|
# @qobj.stubs(:q).returns(@queue)
|
26
26
|
# @qobj.stubs(:mq).returns(@mq)
|
27
27
|
# @qobj.stubs(:ex).returns(@exchange)
|
28
28
|
# @qobj.stubs(:setup)
|
29
29
|
# end
|
30
|
-
#
|
30
|
+
#
|
31
31
|
# it "should register a worker" do
|
32
32
|
# Cloudist.register_worker('make.sandwich', SandwichWorker)
|
33
33
|
# Cloudist.workers.should have_key("make.sandwich")
|
34
34
|
# Cloudist.workers["make.sandwich"].size.should == 1
|
35
35
|
# end
|
36
|
-
#
|
36
|
+
#
|
37
37
|
# it "should support handle syntax" do
|
38
38
|
# Cloudist.workers.should == {}
|
39
39
|
# Cloudist.handle('make.sandwich').with(SandwichWorker)
|
40
40
|
# Cloudist.workers.should have_key("make.sandwich")
|
41
41
|
# Cloudist.workers["make.sandwich"].size.should == 1
|
42
42
|
# end
|
43
|
-
#
|
43
|
+
#
|
44
44
|
# # it "should support handle syntax with multiple queues" do
|
45
45
|
# # Cloudist.workers.should == {}
|
46
46
|
# # Cloudist.handle('make.sandwich', 'eat.sandwich').with(SandwichWorker)
|
47
47
|
# # # Cloudist.workers.should == {"make.sandwich"=>[SandwichWorker], "eat.sandwich"=>[SandwichWorker]}
|
48
48
|
# # end
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# it "should call process on worker when job arrives" do
|
51
51
|
# job = Cloudist.enqueue('make.sandwich', {:bread => 'white'})
|
52
52
|
# job.payload.published?.should be_true
|
@@ -55,5 +55,5 @@ describe "Cloudist" do
|
|
55
55
|
# Cloudist.workers.should have_key("make.sandwich")
|
56
56
|
# Cloudist.workers["make.sandwich"].size.should == 1
|
57
57
|
# end
|
58
|
-
|
58
|
+
|
59
59
|
end
|
@@ -7,10 +7,10 @@ describe "String" do
|
|
7
7
|
"started!".ends_with?('!').should be_true
|
8
8
|
"started!".ends_with?('-').should be_false
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "should support starts_with?" do
|
12
12
|
"event-started".starts_with?("event").should be_true
|
13
13
|
"event-started".starts_with?("reply").should be_false
|
14
14
|
end
|
15
|
-
|
16
|
-
end
|
15
|
+
|
16
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
require 'rspec'
|
4
4
|
require "moqueue"
|
5
|
-
require "mocha"
|
6
5
|
require 'cloudist'
|
7
6
|
|
8
7
|
# Requires supporting files with custom matchers and macros, etc,
|
@@ -10,5 +9,5 @@ require 'cloudist'
|
|
10
9
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
11
10
|
|
12
11
|
RSpec.configure do |config|
|
13
|
-
config.mock_with :
|
12
|
+
config.mock_with :rspec
|
14
13
|
end
|
data/spec/support/amqp.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
def stub_amqp!
|
2
|
-
AMQP.
|
2
|
+
AMQP.stub(:start)
|
3
3
|
mock_queue = mock("AMQP::Queue")
|
4
|
-
mock_queue.
|
5
|
-
mock_queue.
|
6
|
-
|
4
|
+
mock_queue.stub(:bind)
|
5
|
+
mock_queue.stub(:name).and_return("test.queue")
|
6
|
+
|
7
7
|
mock_ex = mock("AMQP::Exchange")
|
8
|
-
mock_ex.
|
9
|
-
|
8
|
+
mock_ex.stub(:name).and_return("test.queue")
|
9
|
+
|
10
10
|
mock_channel = mock("AMQP::Channel")
|
11
|
-
mock_channel.
|
12
|
-
mock_channel.
|
13
|
-
mock_channel.
|
14
|
-
|
15
|
-
AMQP::Channel.
|
11
|
+
mock_channel.stub(:prefetch).with(1)
|
12
|
+
mock_channel.stub(:queue).and_return(mock_queue)
|
13
|
+
mock_channel.stub(:direct).and_return(mock_ex)
|
14
|
+
|
15
|
+
AMQP::Channel.stub(:new).and_return(mock_channel)
|
16
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|
16
|
-
requirement: &
|
16
|
+
requirement: &70159864997720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: 0.8.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70159864997720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70159864997240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.4
|
32
|
+
version: '1.4'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70159864997240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: i18n
|
38
|
-
requirement: &
|
38
|
+
requirement: &70159864996760 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,21 +43,21 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70159864996760
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
|
-
requirement: &
|
49
|
+
requirement: &70159865012640 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ! '>'
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.0.
|
54
|
+
version: 3.0.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70159865012640
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: hashie
|
60
|
-
requirement: &
|
60
|
+
requirement: &70159865012160 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70159865012160
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: uuid
|
71
|
-
requirement: &
|
71
|
+
requirement: &70159865011680 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,21 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: rake
|
82
|
-
requirement: &70283600200220 !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
85
|
-
- - ~>
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: 0.9.2
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *70283600200220
|
79
|
+
version_requirements: *70159865011680
|
91
80
|
- !ruby/object:Gem::Dependency
|
92
81
|
name: rspec
|
93
|
-
requirement: &
|
82
|
+
requirement: &70159865011200 !ruby/object:Gem::Requirement
|
94
83
|
none: false
|
95
84
|
requirements:
|
96
85
|
- - ~>
|
@@ -98,21 +87,10 @@ dependencies:
|
|
98
87
|
version: 2.4.0
|
99
88
|
type: :development
|
100
89
|
prerelease: false
|
101
|
-
version_requirements: *
|
90
|
+
version_requirements: *70159865011200
|
102
91
|
- !ruby/object:Gem::Dependency
|
103
92
|
name: moqueue
|
104
|
-
requirement: &
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: *70283600198460
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
|
-
name: mocha
|
115
|
-
requirement: &70283600197500 !ruby/object:Gem::Requirement
|
93
|
+
requirement: &70159865010720 !ruby/object:Gem::Requirement
|
116
94
|
none: false
|
117
95
|
requirements:
|
118
96
|
- - ! '>='
|
@@ -120,21 +98,10 @@ dependencies:
|
|
120
98
|
version: '0'
|
121
99
|
type: :development
|
122
100
|
prerelease: false
|
123
|
-
version_requirements: *
|
124
|
-
- !ruby/object:Gem::Dependency
|
125
|
-
name: bundler
|
126
|
-
requirement: &70283600196860 !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
|
-
requirements:
|
129
|
-
- - ~>
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.0.0
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: *70283600196860
|
101
|
+
version_requirements: *70159865010720
|
135
102
|
- !ruby/object:Gem::Dependency
|
136
103
|
name: jeweler
|
137
|
-
requirement: &
|
104
|
+
requirement: &70159865010240 !ruby/object:Gem::Requirement
|
138
105
|
none: false
|
139
106
|
requirements:
|
140
107
|
- - ~>
|
@@ -142,21 +109,10 @@ dependencies:
|
|
142
109
|
version: 1.6.4
|
143
110
|
type: :development
|
144
111
|
prerelease: false
|
145
|
-
version_requirements: *
|
146
|
-
- !ruby/object:Gem::Dependency
|
147
|
-
name: rcov
|
148
|
-
requirement: &70283600195440 !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
|
-
requirements:
|
151
|
-
- - ! '>='
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
version: '0'
|
154
|
-
type: :development
|
155
|
-
prerelease: false
|
156
|
-
version_requirements: *70283600195440
|
112
|
+
version_requirements: *70159865010240
|
157
113
|
- !ruby/object:Gem::Dependency
|
158
114
|
name: reek
|
159
|
-
requirement: &
|
115
|
+
requirement: &70159865009760 !ruby/object:Gem::Requirement
|
160
116
|
none: false
|
161
117
|
requirements:
|
162
118
|
- - ~>
|
@@ -164,10 +120,10 @@ dependencies:
|
|
164
120
|
version: 1.2.8
|
165
121
|
type: :development
|
166
122
|
prerelease: false
|
167
|
-
version_requirements: *
|
123
|
+
version_requirements: *70159865009760
|
168
124
|
- !ruby/object:Gem::Dependency
|
169
125
|
name: roodi
|
170
|
-
requirement: &
|
126
|
+
requirement: &70159865009280 !ruby/object:Gem::Requirement
|
171
127
|
none: false
|
172
128
|
requirements:
|
173
129
|
- - ~>
|
@@ -175,7 +131,7 @@ dependencies:
|
|
175
131
|
version: 2.1.0
|
176
132
|
type: :development
|
177
133
|
prerelease: false
|
178
|
-
version_requirements: *
|
134
|
+
version_requirements: *70159865009280
|
179
135
|
description: Cloudist is a simple, highly scalable job queue for Ruby applications,
|
180
136
|
it can run within Rails, DaemonKit or your own custom application. Refer to github
|
181
137
|
page for examples
|
@@ -258,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
258
214
|
version: '0'
|
259
215
|
segments:
|
260
216
|
- 0
|
261
|
-
hash:
|
217
|
+
hash: 3917515305809132007
|
262
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
219
|
none: false
|
264
220
|
requirements:
|
@@ -267,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
223
|
version: '0'
|
268
224
|
requirements: []
|
269
225
|
rubyforge_project:
|
270
|
-
rubygems_version: 1.8.
|
226
|
+
rubygems_version: 1.8.15
|
271
227
|
signing_key:
|
272
228
|
specification_version: 3
|
273
229
|
summary: Super fast job queue using AMQP
|