redis-elasticache 0.1.2 → 0.1.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
  SHA256:
3
- metadata.gz: 2b7bd6bcce6dd8e60cfb6713b12e266d19ea1d89daa620a3cf0cfc0a8132c733
4
- data.tar.gz: 44ed6e3acae5636421987cc2dd7d6aeafd2f607f26606a0a3f30c2b330379e79
3
+ metadata.gz: 7c74a2742340fc6f0ff10c669b43b2d0f7c1a300f49d77500361659fbba49de0
4
+ data.tar.gz: 908669948d0ae1b9b8e04719c4dd97665271da8cb3e3aaaf9d9e7e6a00daa063
5
5
  SHA512:
6
- metadata.gz: 64160ba02b483c108b07b9f15c92d16f9b63e57db83e8b4bb65abf3fee7ea3ae9a3689aa0471b9bb67a691d45be72c6437552b9e2a905368f17a8644b4e1e526
7
- data.tar.gz: 14ebb85c2b8c3a2dabe6865e12f0acd43228d1e3c450cc8a874cbbdc97c0334121bccf7000c9fa9b91c495af9510eda6311a34492e3752ae8a018a267a1c2641
6
+ metadata.gz: 2f9bd873418ddf35846ab8b005bdc327cd4c092bba06d8ebef14c1425b34257a149e181755f522a41bec394ca2cd381a9770443616c44e00dea72c48c77bf781
7
+ data.tar.gz: fdfdc13e8d6d93243cf92c1699bb9bdc0583a117c73461089b23e3f282db95565f5b3f5cb0f2132b56da7fb6c8a0f7d341942710be88ca125d880265064c6fe3
@@ -4,30 +4,33 @@ class Redis
4
4
 
5
5
  module Connection
6
6
  class Ruby
7
-
8
- ELASTICACHE_READONLY_ERROR = "READONLY You can't write against a read only replica.".freeze
9
- ELASTICACHE_LOADING_ERROR = "LOADING Redis is loading the dataset in memory".freeze
7
+ ELASTICACHE_READONLY_ERROR_PREFIX = "READONLY".freeze
8
+ ELASTICACHE_LOADING_ERROR_PREFIX = "LOADING".freeze
10
9
  ELASTICACHE_READONLY_MESSAGE = "A write operation was issued to an ELASTICACHE replica node that is READONLY.".freeze
11
10
  ELASTICACHE_LOADING_MESSAGE = "A write operation was issued to an ELASTICACHE node that was previously READONLY and is now LOADING.".freeze
12
11
 
13
- # Amazon RDS supports failover, but because it uses DNS magic to point to
14
- # the master node, TCP connections are not disconnected and we can issue
15
- # write operations to a node that is no longer the master. Under normal
16
- # conditions this should be interpreted as a `CommandError`, but with RDS
17
- # replication groups, we should consider this a `BaseConnectionError` so we
18
- # terminate the connection, reconnect and retry the operation with the
12
+ # Amazon Elasticache supports failover, but because it uses DNS magic to
13
+ # point to the master node, TCP connections are not disconnected and we
14
+ # can issue write operations to a node that is no longer the master. Under
15
+ # normal conditions this should be interpreted as a `CommandError`, but with
16
+ # Elasticache replication groups, we should consider this a `BaseConnectionError`
17
+ # so we terminate the connection, reconnect and retry the operation with the
19
18
  # correct node as the master accepting writes.
20
19
  def format_error_reply(line)
21
20
  error_message = line.strip
22
- if error_message == ELASTICACHE_READONLY_ERROR
21
+ if error_message_has_prefix?(ELASTICACHE_READONLY_ERROR_PREFIX, error_message)
23
22
  raise BaseConnectionError, ELASTICACHE_READONLY_MESSAGE
24
- elsif error_message == ELASTICACHE_LOADING_ERROR
23
+ elsif error_message_has_prefix?(ELASTICACHE_LOADING_ERROR_PREFIX, error_message)
25
24
  raise BaseConnectionError, ELASTICACHE_LOADING_MESSAGE
26
25
  else
27
26
  CommandError.new(error_message)
28
27
  end
29
28
  end
30
29
 
30
+ private
31
+ def error_message_has_prefix?(prefix, error_message)
32
+ (error_message.slice(0, prefix.length) === prefix)
33
+ end
31
34
  end
32
35
  end
33
36
  end
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  module Elasticache
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-elasticache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig McNamara
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-03-22 00:00:00.000000000 Z
12
+ date: 2019-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis