sensu-transport 8.0.0 → 8.1.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 +26 -17
- 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: b75aa1f55c161361c685e44c5ca7672e921c0894
|
4
|
+
data.tar.gz: fe76b30902129c7b3c0af15eedc09c8629db138c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86fef9f71bc8eeb8f08fd5ab651621021d4d8e06893dc1876dc743cd91fc5b70529cfefe75514008bb40c0ccc8867c5721326ae447e355145efceb56b9bf1e1b
|
7
|
+
data.tar.gz: 24ef7945805c03737ef76ccd3850c77dfdf5b751b7841f81a8cc6762ffc98b0068487c2514999123544e1e96eba74474396c247a967f0521dad8ed729f3d5d4b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -37,22 +37,24 @@ module Sensu
|
|
37
37
|
#
|
38
38
|
# @return [TrueClass, FalseClass]
|
39
39
|
def connected?
|
40
|
-
[@
|
40
|
+
[@primary_connection, @secondary_connection].all? do |connection|
|
41
41
|
connection && connection.connected?
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
# Close the RabbitMQ
|
45
|
+
# Close the RabbitMQ connections.
|
46
46
|
def close
|
47
47
|
callback = Proc.new do
|
48
|
-
[@
|
48
|
+
[@primary_connection, @secondary_connection].each do |connection|
|
49
49
|
connection && connection.close
|
50
50
|
end
|
51
51
|
end
|
52
52
|
connected? ? callback.call : EM.next_tick(callback)
|
53
53
|
end
|
54
54
|
|
55
|
-
# Publish a message to RabbitMQ.
|
55
|
+
# Publish a message to RabbitMQ. This method will only use the
|
56
|
+
# primary channel for publishing keepalive, otherwise it will
|
57
|
+
# use the secondary channel.
|
56
58
|
#
|
57
59
|
# @param type [Symbol] the RabbitMQ exchange type, possible
|
58
60
|
# values are: :direct and :fanout.
|
@@ -66,7 +68,8 @@ module Sensu
|
|
66
68
|
def publish(type, pipe, message, options={})
|
67
69
|
if connected?
|
68
70
|
catch_errors do
|
69
|
-
|
71
|
+
channel = (pipe == "keepalives" ? @primary_channel : @secondary_channel)
|
72
|
+
channel.method(type.to_sym).call(pipe, options).publish(message) do
|
70
73
|
info = {}
|
71
74
|
yield(info) if block_given?
|
72
75
|
end
|
@@ -91,9 +94,9 @@ module Sensu
|
|
91
94
|
def subscribe(type, pipe, funnel="", options={}, &callback)
|
92
95
|
catch_errors do
|
93
96
|
previously_declared = @queues.has_key?(funnel)
|
94
|
-
@queues[funnel] ||= @
|
97
|
+
@queues[funnel] ||= @primary_channel.queue!(funnel, :auto_delete => true)
|
95
98
|
queue = @queues[funnel]
|
96
|
-
queue.bind(@
|
99
|
+
queue.bind(@primary_channel.method(type.to_sym).call(pipe))
|
97
100
|
unless previously_declared
|
98
101
|
queue.subscribe(options, &callback)
|
99
102
|
end
|
@@ -116,7 +119,7 @@ module Sensu
|
|
116
119
|
end
|
117
120
|
end
|
118
121
|
@queues = {}
|
119
|
-
@
|
122
|
+
@primary_channel.recover if connected?
|
120
123
|
end
|
121
124
|
super
|
122
125
|
end
|
@@ -145,7 +148,7 @@ module Sensu
|
|
145
148
|
def stats(funnel, options={})
|
146
149
|
catch_errors do
|
147
150
|
options = options.merge(:auto_delete => true)
|
148
|
-
@
|
151
|
+
@primary_channel.queue(funnel, options).status do |messages, consumers|
|
149
152
|
info = {
|
150
153
|
:messages => messages,
|
151
154
|
:consumers => consumers
|
@@ -175,7 +178,7 @@ module Sensu
|
|
175
178
|
def reset
|
176
179
|
@queues = {}
|
177
180
|
@connection_timeout.cancel if @connection_timeout
|
178
|
-
[@
|
181
|
+
[@primary_connection, @secondary_connection].each do |connection|
|
179
182
|
connection && connection.close_connection
|
180
183
|
end
|
181
184
|
end
|
@@ -208,8 +211,12 @@ module Sensu
|
|
208
211
|
end
|
209
212
|
end
|
210
213
|
|
211
|
-
def
|
212
|
-
|
214
|
+
def channels_ready?(&callback)
|
215
|
+
ready = [@primary_channel, @secondary_channel].all? do |channel|
|
216
|
+
channel && channel.status == :opened
|
217
|
+
end
|
218
|
+
if ready
|
219
|
+
@logger.debug("transport connection ready")
|
213
220
|
@connection_timeout.cancel
|
214
221
|
succeed
|
215
222
|
callback.call if callback
|
@@ -234,7 +241,6 @@ module Sensu
|
|
234
241
|
connection.logger = @logger
|
235
242
|
connection.on_open do
|
236
243
|
@logger.debug("transport connection open")
|
237
|
-
connection_ready(&callback)
|
238
244
|
end
|
239
245
|
connection.on_tcp_connection_loss do
|
240
246
|
@logger.warn("transport connection error", :reason => "tcp connection lost")
|
@@ -265,15 +271,18 @@ module Sensu
|
|
265
271
|
prefetch = options.fetch(:prefetch, 1)
|
266
272
|
end
|
267
273
|
channel.prefetch(prefetch)
|
274
|
+
channel.once_open do
|
275
|
+
channels_ready?(&callback)
|
276
|
+
end
|
268
277
|
channel
|
269
278
|
end
|
270
279
|
|
271
280
|
def connect_with_eligible_options(&callback)
|
272
281
|
next_connection_options do |options|
|
273
|
-
@
|
274
|
-
@
|
275
|
-
@
|
276
|
-
@
|
282
|
+
@primary_connection = setup_connection(options, &callback)
|
283
|
+
@primary_channel = setup_channel(options, @primary_connection)
|
284
|
+
@secondary_connection = setup_connection(options, &callback)
|
285
|
+
@secondary_channel = setup_channel(options, @secondary_connection)
|
277
286
|
end
|
278
287
|
end
|
279
288
|
|
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 = "8.
|
5
|
+
spec.version = "8.1.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: 8.
|
4
|
+
version: 8.1.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-10-
|
33
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: eventmachine
|
metadata.gz.sig
CHANGED
Binary file
|