redis-sentinel 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/redis-sentinel/client.rb +22 -10
- data/lib/redis-sentinel/version.rb +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: 89f65c37fc86df6375c442c0f8aad24eb6d02b7e
|
4
|
+
data.tar.gz: 77ed5c965346ca00f5ce1aec7d30e5a2109ebf7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e486e2b913b004c0ed6fd09c6d80ca905e3f6026d27c523115f9b08895356e761a0def2ecc551a799b554e3a3fe558e3580246e3cc07f7aec0564ff9582ff2de
|
7
|
+
data.tar.gz: 60f1261aff29cf43b2304efb67606e1d631e28a1a711f2b71683d86566845981bc2b86581d66cb528dcba170d4ccd8868ee9ada163dbeb257cab6a33d395a322
|
data/CHANGELOG.md
CHANGED
@@ -82,7 +82,7 @@ class Redis::Client
|
|
82
82
|
rescue Redis::CommandError => e
|
83
83
|
raise unless e.message.include?("IDONTKNOW")
|
84
84
|
rescue Redis::CannotConnectError
|
85
|
-
#
|
85
|
+
# failed to connect to current sentinel server
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -96,21 +96,33 @@ class Redis::Client
|
|
96
96
|
alias disconnect disconnect_with_sentinels
|
97
97
|
|
98
98
|
def call_with_readonly_protection(*args, &block)
|
99
|
-
|
100
|
-
call_without_readonly_protection(*args, &block)
|
101
|
-
rescue Redis::CommandError => e
|
102
|
-
if e.message == "READONLY You can't write against a read only slave."
|
103
|
-
reconnect
|
104
|
-
retry if (tries += 1) < 4
|
105
|
-
else
|
106
|
-
raise
|
107
|
-
end
|
99
|
+
readonly_protection_with_timeout(:call_without_readonly_protection, *args, &block)
|
108
100
|
end
|
109
101
|
|
110
102
|
alias call_without_readonly_protection call
|
111
103
|
alias call call_with_readonly_protection
|
112
104
|
|
105
|
+
def call_pipeline_with_readonly_protection(*args, &block)
|
106
|
+
readonly_protection_with_timeout(:call_pipeline_without_readonly_protection, *args, &block)
|
107
|
+
end
|
108
|
+
|
109
|
+
alias call_pipeline_without_readonly_protection call_pipeline
|
110
|
+
alias call_pipeline call_pipeline_with_readonly_protection
|
111
|
+
|
113
112
|
private
|
113
|
+
def readonly_protection_with_timeout(method, *args, &block)
|
114
|
+
deadline = @failover_reconnect_timeout.to_i + Time.now.to_f
|
115
|
+
send(method, *args, &block)
|
116
|
+
rescue Redis::CommandError => e
|
117
|
+
if e.message.include? "READONLY You can't write against a read only slave."
|
118
|
+
raise if Time.now.to_f > deadline
|
119
|
+
sleep @failover_reconnect_wait
|
120
|
+
reconnect
|
121
|
+
retry
|
122
|
+
else
|
123
|
+
raise
|
124
|
+
end
|
125
|
+
end
|
114
126
|
|
115
127
|
def fetch_option(options, key)
|
116
128
|
options.delete(key) || options.delete(key.to_s)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-sentinel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|