sensu-redis 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sensu/redis.rb +1 -0
- data/lib/sensu/redis/client.rb +4 -2
- data/lib/sensu/redis/sentinel.rb +19 -1
- data/sensu-redis.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 943d104005cbb1b8424389ff4b296aff1eef0479
|
4
|
+
data.tar.gz: f1e7cb7e03104cc4f24c5f5eeb4fea4e272b57fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34128ed6b726437f697b1e91799071c04267ccd4e7b5f5157ac14845133aedefcba10578b43ff7f37f90fec6a858ebe4f47784931d54cd1252a0a57c82171d8
|
7
|
+
data.tar.gz: c92241f1594511f74031827131548f2414c2b067ab983b1f8d126a7dbf5e981d5817785072f2c8500b63bfba4ec5a63770d1620cc8379b0934d2d82bbd7a93f6
|
data/lib/sensu/redis.rb
CHANGED
@@ -42,6 +42,7 @@ module Sensu
|
|
42
42
|
# @yield callback to be called with the redis connection object.
|
43
43
|
def connect_via_sentinel(options, &block)
|
44
44
|
sentinel = Sentinel.new(options)
|
45
|
+
sentinel.logger = @logger
|
45
46
|
sentinel.resolve do |host, port|
|
46
47
|
redis = EM.connect(host, port, Client, options)
|
47
48
|
redis.logger = @logger
|
data/lib/sensu/redis/client.rb
CHANGED
@@ -121,6 +121,7 @@ module Sensu
|
|
121
121
|
# starting the reconnect process when appropriate.
|
122
122
|
def unbind
|
123
123
|
@deferred_status = nil
|
124
|
+
@pubsub_callbacks = nil
|
124
125
|
if @closing
|
125
126
|
@reconnecting = false
|
126
127
|
elsif ((@connected || @reconnecting) && @auto_reconnect) || @reconnect_on_error
|
@@ -189,7 +190,8 @@ module Sensu
|
|
189
190
|
# @param channel [String]
|
190
191
|
# @yield channel message callback.
|
191
192
|
def subscribe(channel, &block)
|
192
|
-
@pubsub_callbacks ||=
|
193
|
+
@pubsub_callbacks ||= {}
|
194
|
+
@pubsub_callbacks[channel] ||= []
|
193
195
|
@pubsub_callbacks[channel] << block
|
194
196
|
redis_command(SUBSCRIBE_COMMAND, channel, &block)
|
195
197
|
end
|
@@ -202,7 +204,7 @@ module Sensu
|
|
202
204
|
# @param channel [String]
|
203
205
|
# @yield unsubscribe callback.
|
204
206
|
def unsubscribe(channel=nil, &block)
|
205
|
-
@pubsub_callbacks ||=
|
207
|
+
@pubsub_callbacks ||= {}
|
206
208
|
arguments = [UNSUBSCRIBE_COMMAND]
|
207
209
|
if channel
|
208
210
|
@pubsub_callbacks[channel] = [block]
|
data/lib/sensu/redis/sentinel.rb
CHANGED
@@ -4,6 +4,8 @@ require "eventmachine"
|
|
4
4
|
module Sensu
|
5
5
|
module Redis
|
6
6
|
class Sentinel
|
7
|
+
attr_accessor :logger
|
8
|
+
|
7
9
|
# Initialize the Sentinel connections. The default Redis master
|
8
10
|
# name is "mymaster", which is the same name that the Sensu HA
|
9
11
|
# Redis documentation uses. The master name must be set
|
@@ -12,7 +14,7 @@ module Sensu
|
|
12
14
|
# @param options [Hash] containing the standard Redis
|
13
15
|
# connection settings.
|
14
16
|
def initialize(options={})
|
15
|
-
@master = options[:master] || "mymaster"
|
17
|
+
@master = options[:master_group] || options[:master] || "mymaster"
|
16
18
|
@sentinels = connect_to_sentinels(options[:sentinels])
|
17
19
|
end
|
18
20
|
|
@@ -78,14 +80,30 @@ module Sensu
|
|
78
80
|
def resolve(&block)
|
79
81
|
sentinel = select_a_sentinel
|
80
82
|
if sentinel.nil?
|
83
|
+
if @logger
|
84
|
+
@logger.debug("unable to determine redis master", {
|
85
|
+
:reason => "not connected to a redis sentinel"
|
86
|
+
})
|
87
|
+
@logger.debug("retrying redis master resolution via redis sentinel")
|
88
|
+
end
|
81
89
|
retry_resolve(&block)
|
82
90
|
else
|
83
91
|
timeout = create_resolve_timeout(sentinel, 10, &block)
|
84
92
|
sentinel.redis_command("sentinel", "get-master-addr-by-name", @master) do |host, port|
|
85
93
|
timeout.cancel
|
86
94
|
if host && port
|
95
|
+
@logger.debug("redis master resolved via redis sentinel", {
|
96
|
+
:host => host,
|
97
|
+
:port => port.to_i
|
98
|
+
}) if @logger
|
87
99
|
block.call(host, port.to_i)
|
88
100
|
else
|
101
|
+
if @logger
|
102
|
+
@logger.debug("unable to determine redis master", {
|
103
|
+
:reason => "redis sentinel did not return a redis master host and port"
|
104
|
+
})
|
105
|
+
@logger.debug("retrying redis master resolution via redis sentinel")
|
106
|
+
end
|
89
107
|
retry_resolve(&block)
|
90
108
|
end
|
91
109
|
end
|
data/sensu-redis.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|