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 +4 -4
- data/lib/sensu/redis/sentinel.rb +22 -11
- data/sensu-redis.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c676e57a1c82b321df2ebe8118ab279e9f63e99
|
4
|
+
data.tar.gz: c5c9e00b13703e168adfdd392f1276946bf3ba65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c22c6a2814798898d765d0e42e6aa812e2ba726c419fcaf4459b9c10840c2a4f402bf7b48c48ed26927c6c60be8bbe295739c8ba303a91740e059f079df2a1d5
|
7
|
+
data.tar.gz: d114c39a00ab8e0db9fc2367065f86e0f380df6e32de3ae8ebdb8cfaf2a5a9304cdf3eef162a3223b9c5d521cac03e43a933e7c0365ef24aee0a4fe2a6c19a62
|
data/lib/sensu/redis/sentinel.rb
CHANGED
@@ -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
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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