redis-reconnect_with_readonly 0.9.2 → 0.9.3

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: 85ea1bdc6974e919bd9c1e8489ab468c94a45177
4
- data.tar.gz: dae0a9aac547e3b4a167dfc377f9941cb5619309
3
+ metadata.gz: 1b4061788f20bca31f019b8768df6d3170635c02
4
+ data.tar.gz: e5f7e654372eb55d40e3f6edc96daafc747ecccd
5
5
  SHA512:
6
- metadata.gz: 3dda7397c1be54f2d14cc69db36f7161ca6c803f4a9f651491c469d69a3d0e6a31a7dc8ed6517436f7cd58a54568927af482fefe181563216ed964396e98f338
7
- data.tar.gz: c018f556bb3e88278da33e880cf3565acb2e7004b3118fd5720e65d39434f0be1896d8c158975441bcedc15e629fcf02fa6f2741cda39c064b886259c182ed41
6
+ metadata.gz: 4d570f5e027a44faa2330eb28140e1c6732adccbab836613d7f8a5587c2d685806110d93313ed4b7121ddf02c4b010eadebf154f0ebf0b805328cfcf4280bff5
7
+ data.tar.gz: fb346107919e998637c6a31bae03ff8ab44b6cad7e5fcf5c9d9355c634a410643a481aee3f9cded50c4ad9e998cae1d9c48894d1d282f33fcafad9e7a4231965
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.9.3 (2016-08-28)
2
+
3
+ Fixes:
4
+
5
+ * raise e on give up
6
+
1
7
  # 0.9.2 (2016-08-28)
2
8
 
3
9
  Enhancements:
@@ -12,34 +12,35 @@ class Redis
12
12
 
13
13
  class << self
14
14
  attr_accessor :reconnect_attempts, :initial_retry_wait, :max_retry_wait, :logger
15
+ end
15
16
 
16
- def reconnect_with_readonly(redis, &block)
17
- retries = 0
18
- begin
19
- yield block
20
- rescue CommandError => e
21
- if e.message =~ /READONLY/
22
- if retries < reconnect_attempts
23
- wait = initial_retry_wait * retries
24
- wait = [wait, max_retry_wait].min if max_retry_wait
25
- logger.info {
26
- "Reconnect with readonly: #{e.message} " \
27
- "(retries: #{retries}/#{reconnect_attempts}) (wait: #{wait}sec)"
28
- } if logger
29
- sleep wait
30
- retries += 1
31
- redis.disconnect
32
- logger.debug { "Reconnect with readonly: disconnected and retry" } if logger
33
- retry
34
- else
35
- logger.info {
36
- "Reconnect with readonly: Give up " \
37
- "(retries: #{retries}/#{reconnect_attempts})"
38
- } if logger
39
- end
17
+ def self.reconnect_with_readonly(redis, &block)
18
+ retries = 0
19
+ begin
20
+ yield block
21
+ rescue CommandError => e
22
+ if e.message =~ /READONLY/
23
+ if retries < reconnect_attempts
24
+ wait = initial_retry_wait * retries
25
+ wait = [wait, max_retry_wait].min if max_retry_wait
26
+ logger.info {
27
+ "Reconnect with readonly: #{e.message} " \
28
+ "(retries: #{retries}/#{reconnect_attempts}) (wait: #{wait}sec)"
29
+ } if logger
30
+ sleep wait
31
+ retries += 1
32
+ redis.disconnect
33
+ logger.debug { "Reconnect with readonly: disconnected and retry" } if logger
34
+ retry
40
35
  else
41
- raise
36
+ logger.info {
37
+ "Reconnect with readonly: Give up " \
38
+ "(retries: #{retries}/#{reconnect_attempts})"
39
+ } if logger
40
+ raise e
42
41
  end
42
+ else
43
+ raise e
43
44
  end
44
45
  end
45
46
  end
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  class ReconnectWithReadonly
3
- VERSION = "0.9.2"
3
+ VERSION = "0.9.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-reconnect_with_readonly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo