pebbles-river 0.3.3 → 0.3.4
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.
- checksums.yaml +4 -4
- data/lib/pebbles/river/river.rb +5 -3
- data/lib/pebbles/river/routing.rb +5 -7
- data/lib/pebbles/river/version.rb +1 -1
- data/lib/pebbles/river/worker.rb +1 -9
- data/spec/lib/routing_spec.rb +1 -1
- data/spec/lib/worker_spec.rb +5 -20
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 849ea26964c3aa0eca352aafc7642748c4eb587f
|
4
|
+
data.tar.gz: f94b8412cffeffc29b4bffcddef89aaf7a7c91d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 795e37fc7303ae8811a3ee0754090ac6b4c4938cb1d51e760dc7c76fecf95dd00651ab400e5ace6370939d0760b79af60486bbd2508b7c1d82fb4ad49972b8ec
|
7
|
+
data.tar.gz: bfdd4900bb2eb74905cc3b6e0eab54251910c0fab32f49c750ca0ec24b3715ea351e72d593f3cbbfec9f7ff798817c28c515d689e4387ae836e50b94c7da580b
|
data/lib/pebbles/river/river.rb
CHANGED
@@ -77,7 +77,7 @@ module Pebbles
|
|
77
77
|
|
78
78
|
def queue(options = {})
|
79
79
|
options.assert_valid_keys(:name, :ttl, :event, :path, :klass,
|
80
|
-
:dead_letter_routing_key, :routing_key)
|
80
|
+
:dead_letter_routing_key, :routing_key, :no_default_routing_keys)
|
81
81
|
|
82
82
|
raise ArgumentError.new 'Queue must be named' unless options[:name]
|
83
83
|
|
@@ -96,8 +96,10 @@ module Pebbles
|
|
96
96
|
if (routing_key = options[:routing_key])
|
97
97
|
queue.bind(exchange.name, key: routing_key)
|
98
98
|
end
|
99
|
-
|
100
|
-
|
99
|
+
unless options[:no_default_routing_keys]
|
100
|
+
Routing.binding_routing_keys_for(options.slice(:event, :class, :path)).each do |key|
|
101
|
+
queue.bind(exchange.name, key: key)
|
102
|
+
end
|
101
103
|
end
|
102
104
|
queue
|
103
105
|
end
|
@@ -15,13 +15,11 @@ module Pebbles
|
|
15
15
|
def self.binding_routing_keys_for(options)
|
16
16
|
options.assert_valid_keys(:path, :class, :event)
|
17
17
|
keys = []
|
18
|
-
|
19
|
-
element_to_routing_key_parts(options[:
|
20
|
-
element_to_routing_key_parts(options[:
|
21
|
-
|
22
|
-
|
23
|
-
keys << [event, klass, path].join('._.')
|
24
|
-
end
|
18
|
+
element_to_routing_key_parts(options[:event]).each do |event|
|
19
|
+
element_to_routing_key_parts(options[:class]).each do |klass|
|
20
|
+
element_to_routing_key_parts(options[:path]).each do |pathspec|
|
21
|
+
path_to_routing_key_parts(pathspec).each do |path|
|
22
|
+
keys << [event, klass, path].join('._.')
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
data/lib/pebbles/river/worker.rb
CHANGED
@@ -181,16 +181,8 @@ module Pebbles
|
|
181
181
|
if @logger
|
182
182
|
@logger.error("Connection error (#{exception.class}): #{exception}")
|
183
183
|
end
|
184
|
-
|
185
184
|
@rate_limiter.increment
|
186
|
-
|
187
|
-
if @queue
|
188
|
-
ignore_exceptions do
|
189
|
-
@queue.close
|
190
|
-
end
|
191
|
-
@queue = nil
|
192
|
-
end
|
193
|
-
|
185
|
+
@queue = nil
|
194
186
|
@river.disconnect
|
195
187
|
rescue Timeout::Error
|
196
188
|
if @logger
|
data/spec/lib/routing_spec.rb
CHANGED
data/spec/lib/worker_spec.rb
CHANGED
@@ -56,6 +56,7 @@ describe Worker do
|
|
56
56
|
|
57
57
|
let :channel do
|
58
58
|
channel = double('Bunny::Channel')
|
59
|
+
channel.stub(:reject) { }
|
59
60
|
channel.stub(:ack) { }
|
60
61
|
channel.stub(:nack) { }
|
61
62
|
channel
|
@@ -63,7 +64,6 @@ describe Worker do
|
|
63
64
|
|
64
65
|
let :queue do
|
65
66
|
queue = double('Bunny::Queue')
|
66
|
-
queue.stub(:close) { nil }
|
67
67
|
queue.stub(:pop) { |&block|
|
68
68
|
block.call(*raw_message)
|
69
69
|
}
|
@@ -151,8 +151,6 @@ describe Worker do
|
|
151
151
|
|
152
152
|
context 'when handler is successful' do
|
153
153
|
it 'acks the message' do
|
154
|
-
expect(queue).to_not receive(:close)
|
155
|
-
|
156
154
|
expect(channel).to receive(:ack).at_least(1).times
|
157
155
|
expect(channel).to_not receive(:nack)
|
158
156
|
|
@@ -166,9 +164,7 @@ describe Worker do
|
|
166
164
|
context 'when handler returns false' do
|
167
165
|
if false # Needs Bunny 0.9+
|
168
166
|
it 'nacks the message' do
|
169
|
-
|
170
|
-
|
171
|
-
expect(channel).to receive(:nack).at_least(1).times
|
167
|
+
expect(channel).to receive(:nack).at_least(1).times
|
172
168
|
expect(channel).to_not receive(:ack)
|
173
169
|
|
174
170
|
expect(river).to receive(:connected?).with(no_args).at_least(1).times
|
@@ -179,9 +175,7 @@ describe Worker do
|
|
179
175
|
else
|
180
176
|
it 'leaves the message un-acked' do
|
181
177
|
expect(queue).to_not receive(:ack)
|
182
|
-
|
183
|
-
|
184
|
-
expect(river).to receive(:connected?).with(no_args).at_least(1).times
|
178
|
+
expect(river).to receive(:connected?).with(no_args).at_least(1).times
|
185
179
|
expect(river).to_not receive(:connect)
|
186
180
|
|
187
181
|
subject.new(false_handler, queue: {name: 'foo'}).run_once
|
@@ -200,16 +194,12 @@ describe Worker do
|
|
200
194
|
if false # Needs Bunny 0.9+
|
201
195
|
it 'nacks the message' do
|
202
196
|
expect(queue).to receive(:nack).at_least(1).times
|
203
|
-
|
204
|
-
|
205
|
-
subject.new(io_error_raising_handler, queue: {name: 'foo'}).run_once
|
197
|
+
subject.new(io_error_raising_handler, queue: {name: 'foo'}).run_once
|
206
198
|
end
|
207
199
|
else
|
208
200
|
it 'leaves the message un-acked' do
|
209
201
|
expect(queue).to_not receive(:ack)
|
210
|
-
|
211
|
-
|
212
|
-
subject.new(io_error_raising_handler, queue: {name: 'foo'}).run_once
|
202
|
+
subject.new(io_error_raising_handler, queue: {name: 'foo'}).run_once
|
213
203
|
end
|
214
204
|
end
|
215
205
|
|
@@ -236,8 +226,6 @@ describe Worker do
|
|
236
226
|
end
|
237
227
|
|
238
228
|
it "performs connection reset on #{exception_class}" do
|
239
|
-
expect(queue).to receive(:close).at_least(1).times
|
240
|
-
|
241
229
|
expect(handler).to receive(:call).with(message)
|
242
230
|
|
243
231
|
expect(river).to receive(:connected?).with(no_args).at_least(1).times
|
@@ -253,8 +241,6 @@ describe Worker do
|
|
253
241
|
on_exception_callback.stub(:call) { }
|
254
242
|
expect(on_exception_callback).to_not receive(:call)
|
255
243
|
|
256
|
-
expect(queue).to receive(:close).at_least(1).times
|
257
|
-
|
258
244
|
expect(handler).to receive(:call).at_least(1).times
|
259
245
|
|
260
246
|
expect(river).to receive(:connected?).with(no_args).at_least(1).times
|
@@ -287,7 +273,6 @@ describe Worker do
|
|
287
273
|
|
288
274
|
context 'non-connection exception' do
|
289
275
|
it "calls #on_exception" do
|
290
|
-
expect(queue).to_not receive(:close)
|
291
276
|
expect(on_exception_callback).to receive(:call).with(io_error)
|
292
277
|
|
293
278
|
subject.new(io_error_raising_handler,
|