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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a79a501844ac25c4bdde61c4801a75e65d22bd0d
4
- data.tar.gz: f40c099446f5b31cc8558aaacb06f8e325381d5f
3
+ metadata.gz: 89f65c37fc86df6375c442c0f8aad24eb6d02b7e
4
+ data.tar.gz: 77ed5c965346ca00f5ce1aec7d30e5a2109ebf7a
5
5
  SHA512:
6
- metadata.gz: 83f3892eacb138abf90d169bb452dc59ff46d91cc25f2581c1278cbf48e026ccc16006db28d92b7041d8c8ce2d2331876619567e1287e713eb3910c27ec70596
7
- data.tar.gz: 90c948ebe4d6bfa1a8a105d79d6e9569cd88cc63988f02c961c11a03f2c3450b63a02de33f6d38bfc1fef71e3b38ce14860f9219dc041bc6424a9a93d316d77e
6
+ metadata.gz: e486e2b913b004c0ed6fd09c6d80ca905e3f6026d27c523115f9b08895356e761a0def2ecc551a799b554e3a3fe558e3580246e3cc07f7aec0564ff9582ff2de
7
+ data.tar.gz: 60f1261aff29cf43b2304efb67606e1d631e28a1a711f2b71683d86566845981bc2b86581d66cb528dcba170d4ccd8868ee9ada163dbeb257cab6a33d395a322
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.4.3
4
+
5
+ * Fix for pipelined requests and readonly calls
6
+
3
7
  ## 1.4.2
4
8
 
5
9
  * Fix sentinel reconnection broken
@@ -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
- # faile to connect to current sentinel server
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
- tries = 0
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)
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  module Sentinel
3
- VERSION = "1.4.2"
3
+ VERSION = "1.4.3"
4
4
  end
5
5
  end
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.2
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-01-23 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis