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 +4 -4
- data/lib/redis/elasticache/failover.rb +14 -11
- data/lib/redis/elasticache/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c74a2742340fc6f0ff10c669b43b2d0f7c1a300f49d77500361659fbba49de0
|
4
|
+
data.tar.gz: 908669948d0ae1b9b8e04719c4dd97665271da8cb3e3aaaf9d9e7e6a00daa063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
14
|
-
# the master node, TCP connections are not disconnected and we
|
15
|
-
# write operations to a node that is no longer the master. Under
|
16
|
-
# conditions this should be interpreted as a `CommandError`, but with
|
17
|
-
# replication groups, we should consider this a `BaseConnectionError`
|
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
|
21
|
+
if error_message_has_prefix?(ELASTICACHE_READONLY_ERROR_PREFIX, error_message)
|
23
22
|
raise BaseConnectionError, ELASTICACHE_READONLY_MESSAGE
|
24
|
-
elsif error_message
|
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
|
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.
|
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-
|
12
|
+
date: 2019-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|