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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bfbf215d8c3a1975203dc6f5c08d65e54ff3167
4
- data.tar.gz: 9ba122e38b68809b037ddf97a338729a6d8104fc
3
+ metadata.gz: 943d104005cbb1b8424389ff4b296aff1eef0479
4
+ data.tar.gz: f1e7cb7e03104cc4f24c5f5eeb4fea4e272b57fd
5
5
  SHA512:
6
- metadata.gz: 0416a9108788879d8cb8a6f688142a85b87f9c5d5a324c0e8301f823557f3d8994b5e2413719e178ed785579fd7e452de6d3ac3c03e7251f6199eef600081b7f
7
- data.tar.gz: 84569b024c3cae5f170ddc0e3c5fa39ebff6b838ed7c6952190c54e236534743f159e7b61c753153ded0d6137b835a991166887dd248fad9f6330d314e98866c
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
@@ -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 ||= Hash.new([])
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 ||= Hash.new([])
207
+ @pubsub_callbacks ||= {}
206
208
  arguments = [UNSUBSCRIBE_COMMAND]
207
209
  if channel
208
210
  @pubsub_callbacks[channel] = [block]
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-redis"
5
- spec.version = "2.0.0"
5
+ spec.version = "2.1.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu Redis client library"
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.0.0
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-06 00:00:00.000000000 Z
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine