redis-cluster-client 0.0.11 → 0.0.12
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 +4 -4
- data/lib/redis_client/cluster/router.rb +15 -6
- 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: 2aec24d7a41cc222cf5fdec13b063d0ce2a68df59c05049a4719f71b6ac07391
|
4
|
+
data.tar.gz: 00b0eebd7da92305fbf2512f660721ad0976cfb1e33fb72037a673fe65899ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28d31d104bd1f2100c0f61c765783e86fea745910c748510bdc7b4985f779df4e8d8240a38afc043504cc36ad33a00273288762defcdcd03e7486cece5351882
|
7
|
+
data.tar.gz: 82a6c2b2e786f27183cc000ca202e4d6bf29b6260dc00a2659eb18660e6e4b3d60946d170606938242dc9340b4ae644aaa15de7369c23e2f9cda0c2bab604fe8
|
@@ -23,7 +23,7 @@ class RedisClient
|
|
23
23
|
@mutex = Mutex.new
|
24
24
|
end
|
25
25
|
|
26
|
-
def send_command(method, *args, **kwargs, &block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
26
|
+
def send_command(method, *args, **kwargs, &block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
27
27
|
command = method == :blocking_call && args.size > 1 ? args[1..] : args
|
28
28
|
|
29
29
|
cmd = command.first.to_s.downcase
|
@@ -34,10 +34,10 @@ class RedisClient
|
|
34
34
|
@node.call_primaries(method, *args, **kwargs, &block).first
|
35
35
|
when 'ping' then @node.send_ping(method, *args, **kwargs, &block).first
|
36
36
|
when 'wait' then send_wait_command(method, *args, **kwargs, &block)
|
37
|
-
when 'keys' then @node.call_replicas(method, *args, **kwargs, &block).flatten.
|
38
|
-
when 'dbsize' then @node.call_replicas(method, *args, **kwargs, &block).sum
|
37
|
+
when 'keys' then @node.call_replicas(method, *args, **kwargs, &block).flatten.sort_by(&:to_s)
|
38
|
+
when 'dbsize' then @node.call_replicas(method, *args, **kwargs, &block).select { |e| e.is_a?(Integer) }.sum
|
39
39
|
when 'scan' then scan(*command, **kwargs)
|
40
|
-
when 'lastsave' then @node.call_all(method, *args, **kwargs, &block).
|
40
|
+
when 'lastsave' then @node.call_all(method, *args, **kwargs, &block).sort_by(&:to_i)
|
41
41
|
when 'role' then @node.call_all(method, *args, **kwargs, &block)
|
42
42
|
when 'config' then send_config_command(method, *args, **kwargs, &block)
|
43
43
|
when 'client' then send_client_command(method, *args, **kwargs, &block)
|
@@ -56,6 +56,11 @@ class RedisClient
|
|
56
56
|
rescue ::RedisClient::Cluster::Node::ReloadNeeded
|
57
57
|
update_cluster_info!
|
58
58
|
raise ::RedisClient::Cluster::NodeMightBeDown
|
59
|
+
rescue ::RedisClient::Cluster::ErrorCollection => e
|
60
|
+
update_cluster_info! if e.errors.values.any? do |err|
|
61
|
+
err.message.start_with?('CLUSTERDOWN Hash slot not served')
|
62
|
+
end
|
63
|
+
raise
|
59
64
|
end
|
60
65
|
|
61
66
|
# @see https://redis.io/topics/cluster-spec#redirection-and-resharding
|
@@ -74,6 +79,10 @@ class RedisClient
|
|
74
79
|
node.call('ASKING')
|
75
80
|
retry_count -= 1
|
76
81
|
retry
|
82
|
+
elsif e.message.start_with?('CLUSTERDOWN Hash slot not served')
|
83
|
+
update_cluster_info!
|
84
|
+
retry_count -= 1
|
85
|
+
retry
|
77
86
|
else
|
78
87
|
raise
|
79
88
|
end
|
@@ -212,11 +221,11 @@ class RedisClient
|
|
212
221
|
command = method == :blocking_call && args.size > 1 ? args[1..] : args
|
213
222
|
|
214
223
|
case command[1].to_s.downcase
|
215
|
-
when 'channels' then @node.call_all(method, *args, **kwargs, &block).flatten.uniq.
|
224
|
+
when 'channels' then @node.call_all(method, *args, **kwargs, &block).flatten.uniq.sort_by(&:to_s)
|
216
225
|
when 'numsub'
|
217
226
|
@node.call_all(method, *args, **kwargs, &block).reject(&:empty?).map { |e| Hash[*e] }
|
218
227
|
.reduce({}) { |a, e| a.merge(e) { |_, v1, v2| v1 + v2 } }
|
219
|
-
when 'numpat' then @node.call_all(method, *args, **kwargs, &block).sum
|
228
|
+
when 'numpat' then @node.call_all(method, *args, **kwargs, &block).select { |e| e.is_a?(Integer) }.sum
|
220
229
|
else assign_node(*command).send(method, *args, **kwargs, &block)
|
221
230
|
end
|
222
231
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-cluster-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taishi Kasuga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|