redis-cluster-client 0.3.9 → 0.3.11
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eb062a2819ec74aebd03e23d7fd55281b8bf600bb5dd9bbcfb4cb36086070ef
|
4
|
+
data.tar.gz: 0bb82a71679f66948d09f07a8e5ccb6b31138e9c1fe7f9d6ab7d10abf35cf473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87727a31dfd4278a353902f31b9bda5f99fe9e0651491f8b2af5bcab16bae819087adff8a8e7ecfdaf81bcd1f99b95e002d66bb4cc44ab690326bcca6c10dd4c
|
7
|
+
data.tar.gz: d4850893095a151cfe5f47a66642fcc311cd58e3466f46f5d8a1ce1e73374ac3f7faaf6b0bcb6ea1f3b18762c3198fad57af33614514280bcac85bfab2af8b08
|
@@ -21,7 +21,7 @@ class RedisClient
|
|
21
21
|
@replications.each_value { |keys| keys.sort_by! { |k| latencies.fetch(k) } }
|
22
22
|
@replica_clients = select_replica_clients(@replications, @clients)
|
23
23
|
@clients_for_scanning = select_clients_for_scanning(@replications, @clients)
|
24
|
-
@existed_replicas = @replications.reject
|
24
|
+
@existed_replicas = @replications.values.reject(&:empty?)
|
25
25
|
end
|
26
26
|
|
27
27
|
def clients_for_scanning(seed: nil) # rubocop:disable Lint/UnusedMethodArgument
|
@@ -43,7 +43,6 @@ class RedisClient
|
|
43
43
|
clients.each_slice(::RedisClient::Cluster::Node::MAX_THREADS).each_with_object({}) do |chuncked_clients, acc|
|
44
44
|
threads = chuncked_clients.map do |k, v|
|
45
45
|
Thread.new(k, v) do |node_key, client|
|
46
|
-
Thread.pass
|
47
46
|
Thread.current.thread_variable_set(:node_key, node_key)
|
48
47
|
|
49
48
|
min = DUMMY_LATENCY_NSEC
|
@@ -18,10 +18,12 @@ class RedisClient
|
|
18
18
|
MAX_STARTUP_SAMPLE = 37
|
19
19
|
MAX_THREADS = Integer(ENV.fetch('REDIS_CLIENT_MAX_THREADS', 5))
|
20
20
|
IGNORE_GENERIC_CONFIG_KEYS = %i[url host port path].freeze
|
21
|
+
SLOT_OPTIMIZATION_STRING = '0' * SLOT_SIZE
|
21
22
|
|
22
23
|
ReloadNeeded = Class.new(::RedisClient::Error)
|
24
|
+
|
23
25
|
Info = Struct.new(
|
24
|
-
'
|
26
|
+
'RedisClusterNode',
|
25
27
|
:id, :node_key, :role, :primary_id, :ping_sent,
|
26
28
|
:pong_recv, :config_epoch, :link_state, :slots,
|
27
29
|
keyword_init: true
|
@@ -35,23 +37,27 @@ class RedisClient
|
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
Slot = Struct.new('StringArray', :string, :elements, keyword_init: true) do
|
41
|
+
def [](index)
|
42
|
+
raise IndexError if index < 0
|
43
|
+
return if index >= string.bytesize
|
44
|
+
|
45
|
+
elements[string.getbyte(index)]
|
43
46
|
end
|
44
47
|
|
45
|
-
def []=(
|
46
|
-
index
|
47
|
-
if index.
|
48
|
-
|
48
|
+
def []=(index, element)
|
49
|
+
raise IndexError if index < 0
|
50
|
+
return if index >= string.bytesize
|
51
|
+
|
52
|
+
pos = elements.find_index(element) # O(N)
|
53
|
+
if pos.nil?
|
54
|
+
raise(RangeError, 'full of elements') if elements.size >= 256
|
49
55
|
|
50
|
-
|
51
|
-
|
56
|
+
pos = elements.size
|
57
|
+
elements << element
|
52
58
|
end
|
53
59
|
|
54
|
-
|
60
|
+
string.setbyte(index, pos)
|
55
61
|
end
|
56
62
|
end
|
57
63
|
|
@@ -79,7 +85,6 @@ class RedisClient
|
|
79
85
|
startup_nodes.each_slice(MAX_THREADS).with_index do |chuncked_startup_nodes, chuncked_idx|
|
80
86
|
threads = chuncked_startup_nodes.each_with_index.map do |raw_client, idx|
|
81
87
|
Thread.new(raw_client, (MAX_THREADS * chuncked_idx) + idx) do |cli, i|
|
82
|
-
Thread.pass
|
83
88
|
Thread.current.thread_variable_set(:index, i)
|
84
89
|
reply = cli.call('CLUSTER', 'NODES')
|
85
90
|
Thread.current.thread_variable_set(:info, parse_cluster_node_reply(reply))
|
@@ -229,7 +234,12 @@ class RedisClient
|
|
229
234
|
def update_slot(slot, node_key)
|
230
235
|
return if @mutex.locked?
|
231
236
|
|
232
|
-
@mutex.synchronize
|
237
|
+
@mutex.synchronize do
|
238
|
+
@slots[slot] = node_key
|
239
|
+
rescue RangeError
|
240
|
+
@slots = Array.new(SLOT_SIZE) { |i| @slots[i] }
|
241
|
+
@slots[slot] = node_key
|
242
|
+
end
|
233
243
|
end
|
234
244
|
|
235
245
|
private
|
@@ -256,11 +266,11 @@ class RedisClient
|
|
256
266
|
end
|
257
267
|
|
258
268
|
def make_array_for_slot_node_mappings(node_info_list)
|
259
|
-
return Array.new(SLOT_SIZE) if node_info_list.count(&:primary?) >
|
269
|
+
return Array.new(SLOT_SIZE) if node_info_list.count(&:primary?) > 256
|
260
270
|
|
261
271
|
::RedisClient::Cluster::Node::Slot.new(
|
262
|
-
|
263
|
-
|
272
|
+
string: String.new(SLOT_OPTIMIZATION_STRING, encoding: Encoding::BINARY, capacity: SLOT_SIZE),
|
273
|
+
elements: node_info_list.select(&:primary?).map(&:node_key)
|
264
274
|
)
|
265
275
|
end
|
266
276
|
|
@@ -293,7 +303,6 @@ class RedisClient
|
|
293
303
|
clients.each_slice(MAX_THREADS) do |chuncked_clients|
|
294
304
|
threads = chuncked_clients.map do |k, v|
|
295
305
|
Thread.new(k, v) do |node_key, client|
|
296
|
-
Thread.pass
|
297
306
|
Thread.current.thread_variable_set(:node_key, node_key)
|
298
307
|
reply = yield(node_key, client)
|
299
308
|
Thread.current.thread_variable_set(:result, reply)
|
@@ -142,7 +142,6 @@ class RedisClient
|
|
142
142
|
@pipelines&.each_slice(MAX_THREADS) do |chuncked_pipelines|
|
143
143
|
threads = chuncked_pipelines.map do |node_key, pipeline|
|
144
144
|
Thread.new(node_key, pipeline) do |nk, pl|
|
145
|
-
Thread.pass
|
146
145
|
Thread.current.thread_variable_set(:node_key, nk)
|
147
146
|
replies = do_pipelining(@router.find_node(nk), pl)
|
148
147
|
raise ReplySizeError, "commands: #{pl._size}, replies: #{replies.size}" if pl._size != replies.size
|
@@ -12,6 +12,7 @@ class RedisClient
|
|
12
12
|
class Cluster
|
13
13
|
class Router
|
14
14
|
ZERO_CURSOR_FOR_SCAN = '0'
|
15
|
+
METHODS_FOR_BLOCKING_CMD = %i[blocking_call_v blocking_call].freeze
|
15
16
|
|
16
17
|
attr_reader :node
|
17
18
|
|
@@ -91,7 +92,7 @@ class RedisClient
|
|
91
92
|
raise
|
92
93
|
end
|
93
94
|
rescue ::RedisClient::ConnectionError => e
|
94
|
-
raise if
|
95
|
+
raise if METHODS_FOR_BLOCKING_CMD.include?(method) && e.is_a?(RedisClient::ReadTimeoutError)
|
95
96
|
raise if retry_count <= 0
|
96
97
|
|
97
98
|
update_cluster_info!
|
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.3.
|
4
|
+
version: 0.3.11
|
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-09-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|