sensu-transport 7.1.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/sensu/transport/rabbitmq.rb +49 -26
- data/sensu-transport.gemspec +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63345aafded68e4d6a2343b8226458471e69c9f3
|
4
|
+
data.tar.gz: 64945aae01510c75c7c981099c5d9ec3ffed582b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c272ca702a01fcd74f58004a666fd52e2f4784b99b3b10db355833d0ed300d826e3b6302189aa5191bfa12b744bc58d815505bc7e57399724c271b1bdf96bd10
|
7
|
+
data.tar.gz: df211a9ecb3b7cab4a4da3c72f0610a522ca36d52704b3283b0873ec45b0542de64ce467c80c5bd572160464a22f0532cd8f01822143bb3f93d215ce28976301
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -37,12 +37,18 @@ module Sensu
|
|
37
37
|
#
|
38
38
|
# @return [TrueClass, FalseClass]
|
39
39
|
def connected?
|
40
|
-
@
|
40
|
+
[@publisher_connection, @consumer_connection].all? do |connection|
|
41
|
+
connection && connection.connected?
|
42
|
+
end
|
41
43
|
end
|
42
44
|
|
43
45
|
# Close the RabbitMQ connection.
|
44
46
|
def close
|
45
|
-
callback = Proc.new
|
47
|
+
callback = Proc.new do
|
48
|
+
[@publisher_connection, @consumer_connection].each do |connection|
|
49
|
+
connection && connection.close
|
50
|
+
end
|
51
|
+
end
|
46
52
|
connected? ? callback.call : EM.next_tick(callback)
|
47
53
|
end
|
48
54
|
|
@@ -60,7 +66,7 @@ module Sensu
|
|
60
66
|
def publish(type, pipe, message, options={})
|
61
67
|
if connected?
|
62
68
|
catch_errors do
|
63
|
-
@
|
69
|
+
@publisher_channel.method(type.to_sym).call(pipe, options).publish(message) do
|
64
70
|
info = {}
|
65
71
|
yield(info) if block_given?
|
66
72
|
end
|
@@ -85,9 +91,9 @@ module Sensu
|
|
85
91
|
def subscribe(type, pipe, funnel="", options={}, &callback)
|
86
92
|
catch_errors do
|
87
93
|
previously_declared = @queues.has_key?(funnel)
|
88
|
-
@queues[funnel] ||= @
|
94
|
+
@queues[funnel] ||= @consumer_channel.queue!(funnel, :auto_delete => true)
|
89
95
|
queue = @queues[funnel]
|
90
|
-
queue.bind(@
|
96
|
+
queue.bind(@consumer_channel.method(type.to_sym).call(pipe))
|
91
97
|
unless previously_declared
|
92
98
|
queue.subscribe(options, &callback)
|
93
99
|
end
|
@@ -110,7 +116,7 @@ module Sensu
|
|
110
116
|
end
|
111
117
|
end
|
112
118
|
@queues = {}
|
113
|
-
@
|
119
|
+
@consumer_channel.recover if connected?
|
114
120
|
end
|
115
121
|
super
|
116
122
|
end
|
@@ -139,7 +145,7 @@ module Sensu
|
|
139
145
|
def stats(funnel, options={})
|
140
146
|
catch_errors do
|
141
147
|
options = options.merge(:auto_delete => true)
|
142
|
-
@
|
148
|
+
@consumer_channel.queue(funnel, options).status do |messages, consumers|
|
143
149
|
info = {
|
144
150
|
:messages => messages,
|
145
151
|
:consumers => consumers
|
@@ -169,7 +175,9 @@ module Sensu
|
|
169
175
|
def reset
|
170
176
|
@queues = {}
|
171
177
|
@connection_timeout.cancel if @connection_timeout
|
172
|
-
@
|
178
|
+
[@publisher_connection, @consumer_connection].each do |connection|
|
179
|
+
connection && connection.close_connection
|
180
|
+
end
|
173
181
|
end
|
174
182
|
|
175
183
|
def set_connection_options(options)
|
@@ -186,7 +194,7 @@ module Sensu
|
|
186
194
|
if @eligible_options.nil? || @eligible_options.empty?
|
187
195
|
@eligible_options = @connection_options.shuffle
|
188
196
|
end
|
189
|
-
options = @eligible_options.shift
|
197
|
+
options = @eligible_options.shift || {}
|
190
198
|
if options.is_a?(Hash) && options[:host]
|
191
199
|
resolve_host(options[:host]) do |ip_address|
|
192
200
|
if ip_address.nil?
|
@@ -200,7 +208,17 @@ module Sensu
|
|
200
208
|
end
|
201
209
|
end
|
202
210
|
|
203
|
-
def
|
211
|
+
def connection_ready(&callback)
|
212
|
+
if connected?
|
213
|
+
@connection_timeout.cancel
|
214
|
+
succeed
|
215
|
+
callback.call if callback
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# @param options [Hash]
|
220
|
+
# @return [Object] RabbitMQ connection.
|
221
|
+
def setup_connection(options={}, &callback)
|
204
222
|
reconnect_callback = Proc.new { reconnect }
|
205
223
|
on_possible_auth_failure = Proc.new {
|
206
224
|
@logger.warn("transport connection error", {
|
@@ -209,34 +227,36 @@ module Sensu
|
|
209
227
|
})
|
210
228
|
reconnect
|
211
229
|
}
|
212
|
-
|
230
|
+
connection = AMQP.connect(options, {
|
213
231
|
:on_tcp_connection_failure => reconnect_callback,
|
214
232
|
:on_possible_authentication_failure => on_possible_auth_failure
|
215
233
|
})
|
216
|
-
|
217
|
-
|
234
|
+
connection.logger = @logger
|
235
|
+
connection.on_open do
|
218
236
|
@logger.debug("transport connection open")
|
219
|
-
|
220
|
-
succeed
|
221
|
-
yield if block_given?
|
237
|
+
connection_ready(&callback)
|
222
238
|
end
|
223
|
-
|
239
|
+
connection.on_tcp_connection_loss do
|
224
240
|
@logger.warn("transport connection error", :reason => "tcp connection lost")
|
225
241
|
reconnect
|
226
242
|
end
|
227
|
-
|
243
|
+
connection.on_skipped_heartbeats do
|
228
244
|
@logger.warn("transport connection error", :reason => "skipped heartbeats")
|
229
245
|
reconnect
|
230
246
|
end
|
231
|
-
|
247
|
+
connection.on_closed do
|
232
248
|
@logger.debug("transport connection closed")
|
233
249
|
end
|
250
|
+
connection
|
234
251
|
end
|
235
252
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
253
|
+
# @param options [Hash]
|
254
|
+
# @param connection [Object] RabbitMQ connection.
|
255
|
+
# @return [Object] RabbitMQ connection channel.
|
256
|
+
def setup_channel(options={}, connection)
|
257
|
+
channel = AMQP::Channel.new(connection)
|
258
|
+
channel.auto_recovery = true
|
259
|
+
channel.on_error do |channel, channel_close|
|
240
260
|
error = Error.new("rabbitmq channel error")
|
241
261
|
@on_error.call(error)
|
242
262
|
end
|
@@ -244,13 +264,16 @@ module Sensu
|
|
244
264
|
if options.is_a?(Hash)
|
245
265
|
prefetch = options.fetch(:prefetch, 1)
|
246
266
|
end
|
247
|
-
|
267
|
+
channel.prefetch(prefetch)
|
268
|
+
channel
|
248
269
|
end
|
249
270
|
|
250
271
|
def connect_with_eligible_options(&callback)
|
251
272
|
next_connection_options do |options|
|
252
|
-
setup_connection(options, &callback)
|
253
|
-
setup_channel(options)
|
273
|
+
@publisher_connection = setup_connection(options, &callback)
|
274
|
+
@publisher_channel = setup_channel(options, @publisher_connection)
|
275
|
+
@consumer_connection = setup_connection(options, &callback)
|
276
|
+
@consumer_channel = setup_channel(options, @consumer_connection)
|
254
277
|
end
|
255
278
|
end
|
256
279
|
|
data/sensu-transport.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "sensu-transport"
|
5
|
-
spec.version = "
|
5
|
+
spec.version = "8.0.0"
|
6
6
|
spec.authors = ["Sean Porter"]
|
7
7
|
spec.email = ["portertech@gmail.com", "engineering@sensu.io"]
|
8
8
|
spec.summary = "The Sensu transport abstraction library"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
jOeGyhtQa9j4FFmsEJDg59f5v/3hECXsa3Xuml3foaFHzX3Ya/YIyd2YFxvkFKIu
|
31
31
|
GVbe7A3YdxzdkH2Es/Ym9twdxXaIDdXzj8sWhw==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-
|
33
|
+
date: 2018-10-11 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: eventmachine
|
metadata.gz.sig
CHANGED
Binary file
|