sensu-redis 0.1.14 → 0.1.15

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: c22a06a2ec430bbba10f536339e6e8bdb9e50dfc
4
- data.tar.gz: 29dfd7de2495c052fa353e01b90e36e7c9ea2ae7
3
+ metadata.gz: 7c676e57a1c82b321df2ebe8118ab279e9f63e99
4
+ data.tar.gz: c5c9e00b13703e168adfdd392f1276946bf3ba65
5
5
  SHA512:
6
- metadata.gz: 244a5a233101f19a973df8153bfeca2c470012b200aacb6a4790e19c3b73c7d11bd29804b29e92a2e1d7d03e7c61bd63c4926e7dda1a2d1e1ab705b66a3cd6ba
7
- data.tar.gz: e4764f5827e5ab8440b259132bf5cd8e75f8ce9fc5038cbdca0e4c0adc1ba4c218c8269570450a3e812d731ecec7e06cfc6190167e4109f9e3f81181fb800538
6
+ metadata.gz: c22c6a2814798898d765d0e42e6aa812e2ba726c419fcaf4459b9c10840c2a4f402bf7b48c48ed26927c6c60be8bbe295739c8ba303a91740e059f079df2a1d5
7
+ data.tar.gz: d114c39a00ab8e0db9fc2367065f86e0f380df6e32de3ae8ebdb8cfaf2a5a9304cdf3eef162a3223b9c5d521cac03e43a933e7c0365ef24aee0a4fe2a6c19a62
@@ -55,6 +55,21 @@ module Sensu
55
55
  end
56
56
  end
57
57
 
58
+
59
+ # Create a Sentinel master resolve timeout, causing the previous
60
+ # attempt to fail/cancel, while beginning another attempt.
61
+ #
62
+ # @param sentinel [Object] connection.
63
+ # @param seconds [Integer] before timeout.
64
+ # @yield callback called when Sentinel resolves the current
65
+ # Redis master address (host & port).
66
+ def create_resolve_timeout(sentinel, seconds, &block)
67
+ EM::Timer.new(seconds) do
68
+ sentinel.fail
69
+ retry_resolve(&block)
70
+ end
71
+ end
72
+
58
73
  # Resolve the current Redis master via Sentinel. The correct
59
74
  # Redis master name is required for this method to work.
60
75
  #
@@ -65,19 +80,15 @@ module Sensu
65
80
  if sentinel.nil?
66
81
  retry_resolve(&block)
67
82
  else
68
- sentinel.callback do
69
- sentinel.send_command("sentinel", "get-master-addr-by-name", @master) do |host, port|
70
- if host && port
71
- block.call(host, port.to_i)
72
- else
73
- retry_resolve(&block)
74
- end
83
+ timeout = create_resolve_timeout(sentinel, 10, &block)
84
+ sentinel.redis_command("sentinel", "get-master-addr-by-name", @master) do |host, port|
85
+ timeout.cancel
86
+ if host && port
87
+ block.call(host, port.to_i)
88
+ else
89
+ retry_resolve(&block)
75
90
  end
76
91
  end
77
- sentinel.errback do
78
- retry_resolve(&block)
79
- end
80
- sentinel.timeout(60)
81
92
  end
82
93
  end
83
94
  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 = "0.1.14"
5
+ spec.version = "0.1.15"
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter