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 +4 -4
- data/lib/pwwka/channel_connector.rb +7 -2
- data/lib/pwwka/version.rb +1 -1
- data/spec/unit/channel_connector_spec.rb +19 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 913ec15d6763b56d762da0c368fa6caba28cc208a18f8aaba9349363e29097ef
|
4
|
+
data.tar.gz: 469f8b149b50c84ced5373ef6fe8cf8533593ecb9f9a0f78eee278b49bccbbd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/pwwka/version.rb
CHANGED
@@ -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
|