queuel 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.irbrc +2 -0
- data/.rspec +2 -0
- data/.rvmrc +46 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +101 -0
- data/Rakefile +6 -0
- data/lib/queuel.rb +68 -0
- data/lib/queuel/client.rb +37 -0
- data/lib/queuel/iron_mq/engine.rb +44 -0
- data/lib/queuel/iron_mq/message.rb +43 -0
- data/lib/queuel/iron_mq/poller.rb +123 -0
- data/lib/queuel/iron_mq/queue.rb +40 -0
- data/lib/queuel/null/engine.rb +12 -0
- data/lib/queuel/null/message.rb +21 -0
- data/lib/queuel/null/poller.rb +120 -0
- data/lib/queuel/null/queue.rb +20 -0
- data/lib/queuel/version.rb +3 -0
- data/queuel.gemspec +28 -0
- data/spec/lib/queuel/client_spec.rb +23 -0
- data/spec/lib/queuel/iron_mq/engine_spec.rb +8 -0
- data/spec/lib/queuel/iron_mq/message_spec.rb +17 -0
- data/spec/lib/queuel/iron_mq/poller_spec.rb +8 -0
- data/spec/lib/queuel/iron_mq/queue_spec.rb +10 -0
- data/spec/lib/queuel/null/engine_spec.rb +8 -0
- data/spec/lib/queuel/null/message_spec.rb +9 -0
- data/spec/lib/queuel/null/poller_spec.rb +9 -0
- data/spec/lib/queuel/null/queue_spec.rb +9 -0
- data/spec/lib/queuel_spec.rb +23 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/engine_shared_example.rb +15 -0
- data/spec/support/message_shared_example.rb +20 -0
- data/spec/support/null_behavior.rb +7 -0
- data/spec/support/poller_shared_example.rb +101 -0
- data/spec/support/queue_shared_example.rb +52 -0
- metadata +217 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
shared_examples "a poller" do
|
2
|
+
let(:message) { double "message" }
|
3
|
+
let(:queue) { double "Queue" }
|
4
|
+
let(:block) { lambda{|m| } }
|
5
|
+
let(:options) { {} }
|
6
|
+
|
7
|
+
subject do
|
8
|
+
described_class.new queue, options, block
|
9
|
+
end
|
10
|
+
|
11
|
+
it { should respond_to :poll }
|
12
|
+
|
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
|
44
|
+
|
45
|
+
it "can poll" do
|
46
|
+
subject.should_receive(:sleep).at_least(10).times
|
47
|
+
subject.poll
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "limited loops" do
|
53
|
+
describe "with 2 yields, one nil" do
|
54
|
+
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)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "can poll" do
|
61
|
+
not_for_null do
|
62
|
+
block.should_receive(:call).once
|
63
|
+
message.should_receive(:delete)
|
64
|
+
subject.poll
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "with timeout" do
|
70
|
+
before do
|
71
|
+
subject.stub timeout: 0.1
|
72
|
+
subject.stub(:pop_new_message).and_return(message, *([nil] * 1500))
|
73
|
+
end
|
74
|
+
|
75
|
+
it "can poll" do
|
76
|
+
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
|
+
subject.poll
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "with max fails" do
|
86
|
+
before do
|
87
|
+
subject.stub max_fails: 10
|
88
|
+
subject.stub(:pop_new_message).and_return(message, *([nil] * 15))
|
89
|
+
end
|
90
|
+
|
91
|
+
it "can poll" do
|
92
|
+
not_for_null do
|
93
|
+
block.should_receive(:call).once
|
94
|
+
message.should_receive(:delete)
|
95
|
+
subject.should_receive(:sleep).exactly(10).times
|
96
|
+
subject.poll
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
shared_examples "a queue" do
|
2
|
+
let(:message) { double "Message" }
|
3
|
+
let(:client) { double "ClientObject" }
|
4
|
+
let(:name) { "venues queue" }
|
5
|
+
subject do
|
6
|
+
described_class.new client, name
|
7
|
+
end
|
8
|
+
|
9
|
+
# Poller object handles this
|
10
|
+
it { should respond_to :receive }
|
11
|
+
it { should respond_to :push }
|
12
|
+
it { should respond_to :pop }
|
13
|
+
|
14
|
+
describe "pop" do
|
15
|
+
describe "with messages" 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 simply return a message" do
|
23
|
+
not_for_null do
|
24
|
+
subject.pop.should be_a Queuel::IronMq::Message
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should delete after bolck" do
|
29
|
+
not_for_null do
|
30
|
+
message.should_receive(:delete)
|
31
|
+
subject.pop { |m| m }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "with nil message" do
|
38
|
+
before do
|
39
|
+
not_for_null do
|
40
|
+
client.stub queue: queue_object_with_nil_message
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should simply return a message" do
|
45
|
+
subject.pop.should == nil
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should delete after bolck" do
|
49
|
+
subject.pop { |m| m } # basically, don't error
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: queuel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jon Phenow
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: simplecov
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: iron_mq
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: typhoeus
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: json
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.7.7
|
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: 1.7.7
|
126
|
+
description: Light Queue wrapper tool
|
127
|
+
email:
|
128
|
+
- j.phenow@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .irbrc
|
135
|
+
- .rspec
|
136
|
+
- .rvmrc
|
137
|
+
- .travis.yml
|
138
|
+
- Gemfile
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- lib/queuel.rb
|
143
|
+
- lib/queuel/client.rb
|
144
|
+
- lib/queuel/iron_mq/engine.rb
|
145
|
+
- lib/queuel/iron_mq/message.rb
|
146
|
+
- lib/queuel/iron_mq/poller.rb
|
147
|
+
- lib/queuel/iron_mq/queue.rb
|
148
|
+
- lib/queuel/null/engine.rb
|
149
|
+
- lib/queuel/null/message.rb
|
150
|
+
- lib/queuel/null/poller.rb
|
151
|
+
- lib/queuel/null/queue.rb
|
152
|
+
- lib/queuel/version.rb
|
153
|
+
- queuel.gemspec
|
154
|
+
- spec/lib/queuel/client_spec.rb
|
155
|
+
- spec/lib/queuel/iron_mq/engine_spec.rb
|
156
|
+
- spec/lib/queuel/iron_mq/message_spec.rb
|
157
|
+
- spec/lib/queuel/iron_mq/poller_spec.rb
|
158
|
+
- spec/lib/queuel/iron_mq/queue_spec.rb
|
159
|
+
- spec/lib/queuel/null/engine_spec.rb
|
160
|
+
- spec/lib/queuel/null/message_spec.rb
|
161
|
+
- spec/lib/queuel/null/poller_spec.rb
|
162
|
+
- spec/lib/queuel/null/queue_spec.rb
|
163
|
+
- spec/lib/queuel_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/support/engine_shared_example.rb
|
166
|
+
- spec/support/message_shared_example.rb
|
167
|
+
- spec/support/null_behavior.rb
|
168
|
+
- spec/support/poller_shared_example.rb
|
169
|
+
- spec/support/queue_shared_example.rb
|
170
|
+
homepage: ''
|
171
|
+
licenses:
|
172
|
+
- MIT
|
173
|
+
post_install_message:
|
174
|
+
rdoc_options: []
|
175
|
+
require_paths:
|
176
|
+
- lib
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
178
|
+
none: false
|
179
|
+
requirements:
|
180
|
+
- - ! '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
segments:
|
184
|
+
- 0
|
185
|
+
hash: 1952946640469032052
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
none: false
|
188
|
+
requirements:
|
189
|
+
- - ! '>='
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
segments:
|
193
|
+
- 0
|
194
|
+
hash: 1952946640469032052
|
195
|
+
requirements: []
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 1.8.25
|
198
|
+
signing_key:
|
199
|
+
specification_version: 3
|
200
|
+
summary: Light Queue wrapper tool
|
201
|
+
test_files:
|
202
|
+
- spec/lib/queuel/client_spec.rb
|
203
|
+
- spec/lib/queuel/iron_mq/engine_spec.rb
|
204
|
+
- spec/lib/queuel/iron_mq/message_spec.rb
|
205
|
+
- spec/lib/queuel/iron_mq/poller_spec.rb
|
206
|
+
- spec/lib/queuel/iron_mq/queue_spec.rb
|
207
|
+
- spec/lib/queuel/null/engine_spec.rb
|
208
|
+
- spec/lib/queuel/null/message_spec.rb
|
209
|
+
- spec/lib/queuel/null/poller_spec.rb
|
210
|
+
- spec/lib/queuel/null/queue_spec.rb
|
211
|
+
- spec/lib/queuel_spec.rb
|
212
|
+
- spec/spec_helper.rb
|
213
|
+
- spec/support/engine_shared_example.rb
|
214
|
+
- spec/support/message_shared_example.rb
|
215
|
+
- spec/support/null_behavior.rb
|
216
|
+
- spec/support/poller_shared_example.rb
|
217
|
+
- spec/support/queue_shared_example.rb
|