sensu-transport 2.2.0 → 2.3.0
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/sensu/transport/rabbitmq.rb +25 -22
- data/sensu-transport.gemspec +1 -1
- data/spec/rabbitmq_spec.rb +2 -2
- 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: b2445b981319329c16442ba79d0cf1bd2e2d07a3
|
4
|
+
data.tar.gz: 5e2c041d677ae778193b4b9c2c5983e5cec0dad7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e61049fd3510dc58237c842d2f71f5f86381695a5380ce9ef6bb64a5d087aa5fd5f1accbc8e852f014eb4799649fed54d03096b4aedc170114db0abb35d19d8c
|
7
|
+
data.tar.gz: ad9bcaa6d5fbd8f08ed8093f168f362c10ebf4b25e26c80f5c264491a9e68cd1bc3a39899f72b8707f557f98682c508d8b56525f28005bfd89618b0e657ddff6
|
@@ -19,16 +19,7 @@ module Sensu
|
|
19
19
|
@reconnecting = true
|
20
20
|
@before_reconnect.call
|
21
21
|
reset
|
22
|
-
|
23
|
-
unless connected?
|
24
|
-
connect_with_eligible_options do
|
25
|
-
@reconnecting = false
|
26
|
-
@after_reconnect.call
|
27
|
-
end
|
28
|
-
else
|
29
|
-
timer.cancel
|
30
|
-
end
|
31
|
-
end
|
22
|
+
periodically_reconnect
|
32
23
|
end
|
33
24
|
end
|
34
25
|
|
@@ -123,13 +114,7 @@ module Sensu
|
|
123
114
|
Proc.new { reconnect }
|
124
115
|
end
|
125
116
|
|
126
|
-
def
|
127
|
-
@logger.error("[amqp] Detected TCP connection failure: #{error}") if @logger
|
128
|
-
reconnect
|
129
|
-
end
|
130
|
-
|
131
|
-
def connect_with_eligible_options(&callback)
|
132
|
-
options = next_connection_options
|
117
|
+
def setup_connection(options={}, &callback)
|
133
118
|
@connection = AMQP.connect(options)
|
134
119
|
@connection.on_tcp_connection_failure(&reconnect_callback)
|
135
120
|
@connection.on_possible_authentication_failure(&reconnect_callback)
|
@@ -140,11 +125,6 @@ module Sensu
|
|
140
125
|
end
|
141
126
|
@connection.on_tcp_connection_loss(&reconnect_callback)
|
142
127
|
@connection.on_skipped_heartbeats(&reconnect_callback)
|
143
|
-
setup_channel(options)
|
144
|
-
rescue EventMachine::ConnectionError => error
|
145
|
-
connection_error(error)
|
146
|
-
rescue Java::JavaLang::RuntimeException => error
|
147
|
-
connection_error(error)
|
148
128
|
end
|
149
129
|
|
150
130
|
def setup_channel(options={})
|
@@ -160,6 +140,29 @@ module Sensu
|
|
160
140
|
end
|
161
141
|
@channel.prefetch(prefetch)
|
162
142
|
end
|
143
|
+
|
144
|
+
def connect_with_eligible_options(&callback)
|
145
|
+
options = next_connection_options
|
146
|
+
setup_connection(options, &callback)
|
147
|
+
setup_channel(options)
|
148
|
+
end
|
149
|
+
|
150
|
+
def periodically_reconnect
|
151
|
+
timer = EM::PeriodicTimer.new(5) do
|
152
|
+
unless connected?
|
153
|
+
begin
|
154
|
+
connect_with_eligible_options do
|
155
|
+
@reconnecting = false
|
156
|
+
@after_reconnect.call
|
157
|
+
end
|
158
|
+
rescue EventMachine::ConnectionError
|
159
|
+
rescue Java::JavaLang::RuntimeException
|
160
|
+
end
|
161
|
+
else
|
162
|
+
timer.cancel
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
163
166
|
end
|
164
167
|
end
|
165
168
|
end
|
data/sensu-transport.gemspec
CHANGED
data/spec/rabbitmq_spec.rb
CHANGED
@@ -108,11 +108,11 @@ describe "Sensu::Transport::RabbitMQ" do
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
it "
|
111
|
+
it "will throw an error if it cannot resolve a hostname" do
|
112
112
|
async_wrapper do
|
113
113
|
expect {
|
114
114
|
@transport.connect(:host => "2def33c3-cfbb-4993-b5ee-08d47f6d8793")
|
115
|
-
}.
|
115
|
+
}.to raise_error
|
116
116
|
async_done
|
117
117
|
end
|
118
118
|
end
|