queuel 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.cane +3 -0
  2. data/.gitignore +1 -1
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile.lock +112 -0
  6. data/Guardfile +22 -0
  7. data/README.md +17 -11
  8. data/Rakefile +7 -0
  9. data/lib/queuel.rb +50 -27
  10. data/lib/queuel/base/engine.rb +35 -0
  11. data/lib/queuel/base/message.rb +32 -0
  12. data/lib/queuel/base/poller.rb +161 -0
  13. data/lib/queuel/base/queue.rb +59 -0
  14. data/lib/queuel/client.rb +15 -3
  15. data/lib/queuel/configurator.rb +65 -0
  16. data/lib/queuel/introspect.rb +11 -0
  17. data/lib/queuel/iron_mq/engine.rb +11 -17
  18. data/lib/queuel/iron_mq/message.rb +5 -26
  19. data/lib/queuel/iron_mq/poller.rb +8 -111
  20. data/lib/queuel/iron_mq/queue.rb +13 -24
  21. data/lib/queuel/null/engine.rb +3 -7
  22. data/lib/queuel/null/message.rb +1 -16
  23. data/lib/queuel/null/poller.rb +2 -114
  24. data/lib/queuel/null/queue.rb +6 -9
  25. data/lib/queuel/version.rb +1 -1
  26. data/queuel.gemspec +10 -0
  27. data/spec/lib/queuel/base/queue_spec.rb +23 -0
  28. data/spec/lib/queuel/client_spec.rb +30 -0
  29. data/spec/lib/queuel/configurator_spec.rb +32 -0
  30. data/spec/lib/queuel/iron_mq/engine_spec.rb +28 -0
  31. data/spec/lib/queuel/iron_mq/message_spec.rb +2 -2
  32. data/spec/lib/queuel/iron_mq/poller_spec.rb +15 -1
  33. data/spec/lib/queuel/iron_mq/queue_spec.rb +2 -2
  34. data/spec/lib/queuel_spec.rb +12 -7
  35. data/spec/spec_helper.rb +4 -0
  36. data/spec/support/engine_shared_example.rb +4 -2
  37. data/spec/support/message_shared_example.rb +2 -11
  38. data/spec/support/poller_shared_example.rb +23 -57
  39. data/spec/support/queue_shared_example.rb +14 -1
  40. metadata +163 -4
@@ -2,19 +2,10 @@ shared_examples "a message" do
2
2
  let(:id) { 1 }
3
3
  let(:body) { "test" }
4
4
  let(:queue) { nil }
5
- subject { described_class.new id, body, queue }
5
+ let(:message_object) { double "wrapped message" }
6
+ subject { described_class.new message_object }
6
7
 
7
8
  it { should respond_to :id }
8
9
  it { should respond_to :body }
9
10
  it { should respond_to :queue }
10
-
11
- its(:queue) { should be_nil }
12
- its(:id) { should == 1 }
13
- its(:body) { should == 'test' }
14
-
15
- describe "with a given queue" do
16
- let(:queue) { double "Queue object" }
17
-
18
- its(:queue) { should == queue }
19
- end
20
11
  end
@@ -1,98 +1,64 @@
1
1
  shared_examples "a poller" do
2
2
  let(:message) { double "message" }
3
- let(:queue) { double "Queue" }
4
- let(:block) { lambda{|m| } }
3
+ let(:queue) { double "Queue", peek: [] }
4
+ let(:block) { lambda{ |m| true } }
5
+ let(:thread_count) { 1 }
5
6
  let(:options) { {} }
6
7
 
7
8
  subject do
8
- described_class.new queue, options, block
9
+ described_class.new queue, block, options, thread_count
9
10
  end
10
11
 
11
12
  it { should respond_to :poll }
12
13
 
13
- describe "nil loops" do
14
- describe "break on nil" do
15
- before do
16
- subject.stub break_if_nil?: true
17
- subject.stub sleep_time: 0
18
- subject.stub pop_new_message: nil
19
- end
20
-
21
- it "can poll" do
22
- subject.should_receive(:sleep).exactly(1).times
23
- subject.poll
24
- end
25
- end
26
-
27
- describe "with max fails" do
28
- before do
29
- subject.stub max_fails: 10
30
- subject.stub(:pop_new_message).and_return(*([nil] * 15))
31
- end
32
-
33
- it "can poll" do
34
- subject.should_receive(:sleep).exactly(10).times
35
- subject.poll
36
- end
37
- end
38
-
39
- describe "with timeout" do
40
- before do
41
- subject.stub timeout: 0.1
42
- subject.stub(:pop_new_message).and_return(*([nil] * 1500))
43
- end
14
+ describe "profiling", perf: true do
15
+ let(:magnitude) { 3000 }
44
16
 
45
- it "can poll" do
46
- subject.should_receive(:sleep).at_least(10).times
47
- subject.poll
48
- end
17
+ before do
18
+ message.stub delete: true
19
+ subject.stub quit_on_empty?: true
20
+ subject.stub(:pop_new_message).and_return(*([message]*magnitude), nil)
49
21
  end
50
- end
51
22
 
52
- describe "limited loops" do
53
- describe "with 2 yields, one nil" do
23
+ describe "with 1 thread" do
24
+ let(:thread_count) { 1 }
54
25
  before do
55
- subject.stub break_if_nil?: true
56
- subject.stub sleep_time: 0
57
- subject.stub(:pop_new_message).and_return(message, nil)
26
+ queue.stub(:peek).and_return *([message] * magnitude), nil
58
27
  end
59
28
 
60
29
  it "can poll" do
61
30
  not_for_null do
62
- block.should_receive(:call).once
63
- message.should_receive(:delete)
64
31
  subject.poll
65
32
  end
66
33
  end
67
34
  end
68
35
 
69
- describe "with timeout" do
36
+ describe "with 3 threads" do
37
+ let(:thread_count) { 3 }
70
38
  before do
71
- subject.stub timeout: 0.1
72
- subject.stub(:pop_new_message).and_return(message, *([nil] * 1500))
39
+ queue.stub(:peek).and_return *([message, message, message] * (magnitude/3)), nil
73
40
  end
74
41
 
75
42
  it "can poll" do
76
43
  not_for_null do
77
- block.should_receive(:call).once
78
- message.should_receive(:delete)
79
- subject.should_receive(:sleep).at_least(10).times
80
44
  subject.poll
81
45
  end
82
46
  end
83
47
  end
48
+ end
84
49
 
85
- describe "with max fails" do
50
+ describe "limited loops" do
51
+ describe "with 2 yields, one nil" do
86
52
  before do
87
- subject.stub max_fails: 10
88
- subject.stub(:pop_new_message).and_return(message, *([nil] * 15))
53
+ subject.stub quit_on_empty?: true
54
+ queue.stub(:peek).and_return [message], nil
55
+ subject.stub(:pop_new_message).and_return(message, nil)
89
56
  end
90
57
 
91
58
  it "can poll" do
92
59
  not_for_null do
93
- block.should_receive(:call).once
60
+ block.should_receive(:call).once.and_return true
94
61
  message.should_receive(:delete)
95
- subject.should_receive(:sleep).exactly(10).times
96
62
  subject.poll
97
63
  end
98
64
  end
@@ -1,5 +1,5 @@
1
1
  shared_examples "a queue" do
2
- let(:message) { double "Message" }
2
+ let(:message) { double "Message", body: "uhuh" }
3
3
  let(:client) { double "ClientObject" }
4
4
  let(:name) { "venues queue" }
5
5
  subject do
@@ -10,6 +10,19 @@ shared_examples "a queue" do
10
10
  it { should respond_to :receive }
11
11
  it { should respond_to :push }
12
12
  it { should respond_to :pop }
13
+ it { should respond_to :peek }
14
+
15
+ describe "peek" do
16
+ before do
17
+ not_for_null do
18
+ client.stub queue: queue_object_with_message
19
+ end
20
+ end
21
+
22
+ it "should take options and return an array" do
23
+ subject.peek(option: true).should be_an Array
24
+ end
25
+ end
13
26
 
14
27
  describe "pop" do
15
28
  describe "with messages" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-14 00:00:00.000000000 Z
12
+ date: 2013-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -107,6 +107,118 @@ dependencies:
107
107
  - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: guard-bundler
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: guard-rspec
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: guard-cane
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: rb-inotify
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: rb-fsevent
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: rb-fchange
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: cane
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
110
222
  - !ruby/object:Gem::Dependency
111
223
  name: json
112
224
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +235,38 @@ dependencies:
123
235
  - - ~>
124
236
  - !ruby/object:Gem::Version
125
237
  version: 1.7.7
238
+ - !ruby/object:Gem::Dependency
239
+ name: thread
240
+ requirement: !ruby/object:Gem::Requirement
241
+ none: false
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ type: :runtime
247
+ prerelease: false
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
254
+ - !ruby/object:Gem::Dependency
255
+ name: mono_logger
256
+ requirement: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ! '>='
260
+ - !ruby/object:Gem::Version
261
+ version: '0'
262
+ type: :runtime
263
+ prerelease: false
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
126
270
  description: Light Queue wrapper tool
127
271
  email:
128
272
  - j.phenow@gmail.com
@@ -130,17 +274,28 @@ executables: []
130
274
  extensions: []
131
275
  extra_rdoc_files: []
132
276
  files:
277
+ - .cane
133
278
  - .gitignore
134
279
  - .irbrc
135
280
  - .rspec
281
+ - .ruby-gemset
282
+ - .ruby-version
136
283
  - .rvmrc
137
284
  - .travis.yml
138
285
  - Gemfile
286
+ - Gemfile.lock
287
+ - Guardfile
139
288
  - LICENSE.txt
140
289
  - README.md
141
290
  - Rakefile
142
291
  - lib/queuel.rb
292
+ - lib/queuel/base/engine.rb
293
+ - lib/queuel/base/message.rb
294
+ - lib/queuel/base/poller.rb
295
+ - lib/queuel/base/queue.rb
143
296
  - lib/queuel/client.rb
297
+ - lib/queuel/configurator.rb
298
+ - lib/queuel/introspect.rb
144
299
  - lib/queuel/iron_mq/engine.rb
145
300
  - lib/queuel/iron_mq/message.rb
146
301
  - lib/queuel/iron_mq/poller.rb
@@ -151,7 +306,9 @@ files:
151
306
  - lib/queuel/null/queue.rb
152
307
  - lib/queuel/version.rb
153
308
  - queuel.gemspec
309
+ - spec/lib/queuel/base/queue_spec.rb
154
310
  - spec/lib/queuel/client_spec.rb
311
+ - spec/lib/queuel/configurator_spec.rb
155
312
  - spec/lib/queuel/iron_mq/engine_spec.rb
156
313
  - spec/lib/queuel/iron_mq/message_spec.rb
157
314
  - spec/lib/queuel/iron_mq/poller_spec.rb
@@ -182,7 +339,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
339
  version: '0'
183
340
  segments:
184
341
  - 0
185
- hash: 1952946640469032052
342
+ hash: 666822157956022088
186
343
  required_rubygems_version: !ruby/object:Gem::Requirement
187
344
  none: false
188
345
  requirements:
@@ -191,7 +348,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
348
  version: '0'
192
349
  segments:
193
350
  - 0
194
- hash: 1952946640469032052
351
+ hash: 666822157956022088
195
352
  requirements: []
196
353
  rubyforge_project:
197
354
  rubygems_version: 1.8.25
@@ -199,7 +356,9 @@ signing_key:
199
356
  specification_version: 3
200
357
  summary: Light Queue wrapper tool
201
358
  test_files:
359
+ - spec/lib/queuel/base/queue_spec.rb
202
360
  - spec/lib/queuel/client_spec.rb
361
+ - spec/lib/queuel/configurator_spec.rb
203
362
  - spec/lib/queuel/iron_mq/engine_spec.rb
204
363
  - spec/lib/queuel/iron_mq/message_spec.rb
205
364
  - spec/lib/queuel/iron_mq/poller_spec.rb