pwwka 0.21.1 → 0.21.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 203046e40a742cdaa8e606739292777af728af3931b26f5ded94718a7cc5b3a6
4
- data.tar.gz: 4448188accc4a71b4a4ee82fdb2f53a85eef1d94d19e9711ced0626f399dc449
3
+ metadata.gz: 913ec15d6763b56d762da0c368fa6caba28cc208a18f8aaba9349363e29097ef
4
+ data.tar.gz: 469f8b149b50c84ced5373ef6fe8cf8533593ecb9f9a0f78eee278b49bccbbd1
5
5
  SHA512:
6
- metadata.gz: e5a528af9bf9665fcddd319690431755951f0afee95f0b2f5de93e71611c85c28fb70f880ec4c156bdabfbe3586f75b721eaeb38196d2669fdbaf6ba3f290004
7
- data.tar.gz: 601734c090c23ec549c2a7ab65b245984c7c276e45d14df975c6ed028488525c4d3cef06793d6f785dd66a98b45ada1de78368f9a7e72595681d2ed66dade04e
6
+ metadata.gz: 3d5ac493402d2afd1857ee86faa80b4043d91a4d7dc2837beb3fb9a8ff5cb729af4b9d00f2e7d763f9513856d2f3f518cde6c08710c2f9221240136d0ac31255
7
+ data.tar.gz: 41a48b20fa6a9fbc47383cd3d993372f8b0ad3a2fa4ddd0e85c6948dd07c469bfe2090b83aa62f7bc58a3067db443d90caa9b2f6f4ed7d98314bb7520d1ca99b
@@ -1,5 +1,7 @@
1
1
  module Pwwka
2
2
  class ChannelConnector
3
+ extend Pwwka::Logging
4
+ include Pwwka::Logging
3
5
 
4
6
  attr_reader :connection
5
7
  attr_reader :configuration
@@ -12,13 +14,16 @@ module Pwwka
12
14
  @configuration = Pwwka.configuration
13
15
  connection_options = {automatically_recover: false}.merge(configuration.options)
14
16
  connection_options = {client_properties: {connection_name: connection_name}}.merge(connection_options) if connection_name
15
- @connection = Bunny.new(configuration.rabbit_mq_host,
16
- connection_options)
17
+ @connection = Bunny.new(configuration.rabbit_mq_host, connection_options)
17
18
  @connection.start
18
19
  @channel = @connection.create_channel
19
20
  if prefetch
20
21
  @channel.prefetch(prefetch.to_i)
21
22
  end
23
+ rescue => e
24
+ logf "ERROR Connecting to RabbitMQ", error: e
25
+ @connection.close if @connection
26
+ raise e
22
27
  end
23
28
 
24
29
  def topic_exchange
@@ -1,4 +1,4 @@
1
1
  module Pwwka
2
- VERSION = '0.21.1'
2
+ VERSION = '0.21.2'
3
3
  end
4
4
 
@@ -12,6 +12,7 @@ describe Pwwka::ChannelConnector do
12
12
  before do
13
13
  allow(Bunny).to receive(:new).and_return(bunny_session)
14
14
  allow(bunny_session).to receive(:start)
15
+ allow(bunny_session).to receive(:close)
15
16
  allow(bunny_session).to receive(:create_channel).and_return(bunny_channel)
16
17
  end
17
18
 
@@ -45,6 +46,24 @@ describe Pwwka::ChannelConnector do
45
46
  described_class.new
46
47
  end
47
48
 
49
+ context "error during connection start" do
50
+ before do
51
+ allow(bunny_session).to receive(:start).and_raise("Connection Error!")
52
+ end
53
+ it "closes the connection" do
54
+ begin
55
+ described_class.new
56
+ rescue => ex
57
+ end
58
+ expect(bunny_session).to have_received(:close)
59
+ end
60
+ it "raises an error" do
61
+ expect {
62
+ described_class.new
63
+ }.to raise_error(/Connection Error!/)
64
+ end
65
+ end
66
+
48
67
  end
49
68
 
50
69
  describe "raise_if_delayed_not_allowed" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwwka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.1
4
+ version: 0.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stitch Fix Engineering