redis-cluster-client 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_client/cluster/command.rb +11 -5
- data/lib/redis_client/cluster/errors.rb +1 -7
- data/lib/redis_client/cluster/node.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86d73675660702eb937b5d27925248d16b64fe46306d49da0c2b89ee49b5dc34
|
4
|
+
data.tar.gz: d2472791161a5ba746cc29c504353dc0e8414c093a531ff1017653a5a354d7dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd12c8ebbc013d36ead0ee5bb4f8914ad8e5dec4a302e1aa54890ba36abd2358376bc0329e94b859c9e5c5d71d1a07d11a2f9684db655fef375000e792ca5f0c
|
7
|
+
data.tar.gz: d05782f64503cc104ef789683448d967ca6d71355cdc8a1411e8a92ea98f9412ad94a7a411bc0a93ffffb5ff384f6d3fb6e48ef83cc07bf0fe907872045e2567
|
@@ -7,15 +7,21 @@ class RedisClient
|
|
7
7
|
class Cluster
|
8
8
|
class Command
|
9
9
|
class << self
|
10
|
-
def load(nodes)
|
11
|
-
errors =
|
10
|
+
def load(nodes) # rubocop:disable Metrics/MethodLength
|
11
|
+
errors = []
|
12
|
+
cmd = nil
|
13
|
+
nodes&.each do |node|
|
14
|
+
break unless cmd.nil?
|
15
|
+
|
12
16
|
reply = node.call('COMMAND')
|
13
17
|
details = parse_command_details(reply)
|
14
|
-
|
15
|
-
rescue ::RedisClient::
|
16
|
-
e
|
18
|
+
cmd = ::RedisClient::Cluster::Command.new(details)
|
19
|
+
rescue ::RedisClient::Error => e
|
20
|
+
errors << e
|
17
21
|
end
|
18
22
|
|
23
|
+
return cmd unless cmd.nil?
|
24
|
+
|
19
25
|
raise ::RedisClient::Cluster::InitialSetupError, errors
|
20
26
|
end
|
21
27
|
|
@@ -6,8 +6,6 @@ class RedisClient
|
|
6
6
|
class Cluster
|
7
7
|
ERR_ARG_NORMALIZATION = ->(arg) { Array[arg].flatten.reject { |e| e.nil? || (e.respond_to?(:empty?) && e.empty?) } }
|
8
8
|
|
9
|
-
# Raised when client connected to redis as cluster mode
|
10
|
-
# and failed to fetch cluster state information by commands.
|
11
9
|
class InitialSetupError < ::RedisClient::Error
|
12
10
|
def initialize(errors)
|
13
11
|
msg = ERR_ARG_NORMALIZATION.call(errors).map(&:message).uniq.join(',')
|
@@ -15,8 +13,6 @@ class RedisClient
|
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
|
-
# Raised when client connected to redis as cluster mode
|
19
|
-
# and some cluster subcommands were called.
|
20
16
|
class OrchestrationCommandNotSupported < ::RedisClient::Error
|
21
17
|
def initialize(command)
|
22
18
|
str = ERR_ARG_NORMALIZATION.call(command).map(&:to_s).join(' ').upcase
|
@@ -28,7 +24,6 @@ class RedisClient
|
|
28
24
|
end
|
29
25
|
end
|
30
26
|
|
31
|
-
# Raised when error occurs on any node of cluster.
|
32
27
|
class ErrorCollection < ::RedisClient::Error
|
33
28
|
attr_reader :errors
|
34
29
|
|
@@ -41,11 +36,10 @@ class RedisClient
|
|
41
36
|
|
42
37
|
@errors = errors
|
43
38
|
messages = @errors.map { |node_key, error| "#{node_key}: #{error.message}" }
|
44
|
-
super("
|
39
|
+
super("Errors occurred on any node: #{messages.join(', ')}")
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
48
|
-
# Raised when cluster client can't select node.
|
49
43
|
class AmbiguousNodeError < ::RedisClient::Error
|
50
44
|
def initialize(command)
|
51
45
|
super("Cluster client doesn't know which node the #{command} command should be sent to.")
|