beetle 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6b1de828dca7a94962097fa30763c18944837e8
4
- data.tar.gz: b52dcbee0773bfa70d22f204942e97398262dbd0
3
+ metadata.gz: 3d8b222ecf61bf82a5c7969fb525aa19a42aa2d7
4
+ data.tar.gz: 2058829e3453e484cf1d226c01fcfe8c50b32fda
5
5
  SHA512:
6
- metadata.gz: f33209c5bbf8125e84713bb19837c14cf19ca508d46b7c24f9496abb9969edfd423d9f38a064ba8a4cf0d72520ea4e73e02251c827732efe4894a3bf1cfb2687
7
- data.tar.gz: 17b50f9b57f777843f41960a6129e686b4191b2b3e5557f21c931ad6ed37341a0c7fa8b681044bc1c7bce1f75b85416ce62304ba79e78e6cf84dc16d278f529d
6
+ metadata.gz: f91ee3a7c83f9f3823b43a5e0cae3447c5d9fe11c7b7eca32469d0bb7f1a7fe7df435fe1e172b5a916cd16fe7c656cd30cb530d12b2d88d091037a01b7b814f7
7
+ data.tar.gz: b10f5d7895227dade91634ff95468a28a75393f14629704fa3dd7f4d43472c0a8374ff47804408c1059e45f557582c79e58e0590e39d8801ef675fc1ec7dc08a
data/RELEASE_NOTES.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = Release Notes
2
2
 
3
+ == Version 1.0.1
4
+
5
+ * don't try to connect on publisher shutdown
6
+
3
7
  == Version 1.0.0
4
8
 
5
9
  * introduced semantic versioning
@@ -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
- begin
221
- Beetle::Timer.timeout(1) do
222
- logger.debug "Beetle: closing connection from publisher to #{server}"
223
- if exception
224
- bunny.__send__ :close_socket
225
- else
226
- bunny.stop
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
@@ -1,3 +1,3 @@
1
1
  module Beetle
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beetle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes