beetle 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/RELEASE_NOTES.rdoc +4 -0
- data/lib/beetle/publisher.rb +18 -15
- data/lib/beetle/version.rb +1 -1
- data/test/beetle/publisher_test.rb +12 -0
- 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: 3d8b222ecf61bf82a5c7969fb525aa19a42aa2d7
|
4
|
+
data.tar.gz: 2058829e3453e484cf1d226c01fcfe8c50b32fda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f91ee3a7c83f9f3823b43a5e0cae3447c5d9fe11c7b7eca32469d0bb7f1a7fe7df435fe1e172b5a916cd16fe7c656cd30cb530d12b2d88d091037a01b7b814f7
|
7
|
+
data.tar.gz: b10f5d7895227dade91634ff95468a28a75393f14629704fa3dd7f4d43472c0a8374ff47804408c1059e45f557582c79e58e0590e39d8801ef675fc1ec7dc08a
|
data/RELEASE_NOTES.rdoc
CHANGED
data/lib/beetle/publisher.rb
CHANGED
@@ -153,6 +153,10 @@ module Beetle
|
|
153
153
|
@bunnies[@server] ||= new_bunny
|
154
154
|
end
|
155
155
|
|
156
|
+
def bunny?
|
157
|
+
@bunnies[@server]
|
158
|
+
end
|
159
|
+
|
156
160
|
def new_bunny
|
157
161
|
b = Bunny.new(
|
158
162
|
:host => current_host,
|
@@ -217,23 +221,22 @@ module Beetle
|
|
217
221
|
end
|
218
222
|
|
219
223
|
def stop!(exception=nil)
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
end
|
224
|
+
return unless bunny?
|
225
|
+
Beetle::Timer.timeout(1) do
|
226
|
+
logger.debug "Beetle: closing connection from publisher to #{server}"
|
227
|
+
if exception
|
228
|
+
bunny.__send__ :close_socket
|
229
|
+
else
|
230
|
+
bunny.stop
|
228
231
|
end
|
229
|
-
rescue Exception => e
|
230
|
-
logger.warn "Beetle: error closing down bunny #{e}"
|
231
|
-
Beetle::reraise_expectation_errors!
|
232
|
-
ensure
|
233
|
-
@bunnies[@server] = nil
|
234
|
-
@exchanges[@server] = {}
|
235
|
-
@queues[@server] = {}
|
236
232
|
end
|
233
|
+
rescue Exception => e
|
234
|
+
logger.warn "Beetle: error closing down bunny: #{e}"
|
235
|
+
Beetle::reraise_expectation_errors!
|
236
|
+
ensure
|
237
|
+
@bunnies[@server] = nil
|
238
|
+
@exchanges[@server] = {}
|
239
|
+
@queues[@server] = {}
|
237
240
|
end
|
238
241
|
end
|
239
242
|
end
|
data/lib/beetle/version.rb
CHANGED
@@ -42,6 +42,7 @@ module Beetle
|
|
42
42
|
test "stop! should shut down bunny and clean internal data structures" do
|
43
43
|
b = mock("bunny")
|
44
44
|
b.expects(:stop).raises(Exception.new)
|
45
|
+
@pub.expects(:bunny?).returns(true)
|
45
46
|
@pub.expects(:bunny).returns(b)
|
46
47
|
@pub.send(:stop!)
|
47
48
|
assert_equal({}, @pub.send(:exchanges))
|
@@ -49,6 +50,15 @@ module Beetle
|
|
49
50
|
assert_nil @pub.instance_variable_get(:@bunnies)[@pub.server]
|
50
51
|
end
|
51
52
|
|
53
|
+
test "stop! should not create a new bunny " do
|
54
|
+
@pub.expects(:bunny?).returns(false)
|
55
|
+
@pub.expects(:bunny).never
|
56
|
+
@pub.send(:stop!)
|
57
|
+
assert_equal({}, @pub.send(:exchanges))
|
58
|
+
assert_equal({}, @pub.send(:queues))
|
59
|
+
assert_nil @pub.instance_variable_get(:@bunnies)[@pub.server]
|
60
|
+
end
|
61
|
+
|
52
62
|
end
|
53
63
|
|
54
64
|
class PublisherPublishingTest < Minitest::Test
|
@@ -403,9 +413,11 @@ module Beetle
|
|
403
413
|
s = sequence("shutdown")
|
404
414
|
bunny = mock("bunny")
|
405
415
|
@pub.expects(:set_current_server).with("localhost:1111").in_sequence(s)
|
416
|
+
@pub.expects(:bunny?).returns(true).in_sequence(s)
|
406
417
|
@pub.expects(:bunny).returns(bunny).in_sequence(s)
|
407
418
|
bunny.expects(:stop).in_sequence(s)
|
408
419
|
@pub.expects(:set_current_server).with("localhost:2222").in_sequence(s)
|
420
|
+
@pub.expects(:bunny?).returns(true).in_sequence(s)
|
409
421
|
@pub.expects(:bunny).returns(bunny).in_sequence(s)
|
410
422
|
bunny.expects(:stop).in_sequence(s)
|
411
423
|
@pub.stop
|