redis-cluster-client 0.11.3 → 0.11.5

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: a18bda4b076ac6a39e7558b39b0ff5f443e2f9d192ff45ee6749e64b3a349fbd
4
- data.tar.gz: ed166898e6dbb23b316d87162767fe06eb34440029bdb6f33764c58038c20d88
3
+ metadata.gz: 175bb2bf9b82d2b1d0b95e8d7e3e74e3952165f2edea957303f8b16716a17273
4
+ data.tar.gz: 1e094b0d0ae859cb4d77cc872203c21f2f408b739a748d518fd60ca7c33e7451
5
5
  SHA512:
6
- metadata.gz: 7b1ca4265e58d3d4cdb00c0ad9629d72dec6c1a0681d34663e38adb147a0d66985be3f4257d6f6d0c62752cda0f710bfd9e7eb9f3694e07ec4796ce99677c148
7
- data.tar.gz: 178592be6e79bfdf2c5288f558fca21116aabd98cc10b4436298393d22f895844523b3e32f28635172229a404c55d83e52e242230677ab00d509dba7d70adc0c
6
+ metadata.gz: 8b8a13a4df4b5d96da3bcb618bada62d5882fb688b7fd7a9d618c6733a44913af24222c48d40f4db0a316d58b00aa608de99467114dac22711eb7b421f7e2e8a
7
+ data.tar.gz: 2c3ebd371f3a23388e6600192a6403c5f97a90f7a7c06bab747310fa729d8be8f9d7d793763a8e7829f2e4699893d76964a96bd0ea40e727d0bdb499e1ef9f67
@@ -37,8 +37,8 @@ class RedisClient
37
37
  end
38
38
 
39
39
  @errors = errors
40
- messages = @errors.map { |node_key, error| "#{node_key}: #{error.message}" }
41
- super("Errors occurred on any node: #{messages.join(', ')}")
40
+ messages = @errors.map { |node_key, error| "#{node_key}: (#{error.class}) #{error.message}" }
41
+ super(messages.join(', '))
42
42
  end
43
43
  end
44
44
 
@@ -309,7 +309,7 @@ class RedisClient
309
309
  work_group.push(i, raw_client) do |client|
310
310
  regular_timeout = client.read_timeout
311
311
  client.read_timeout = @config.slow_command_timeout > 0.0 ? @config.slow_command_timeout : regular_timeout
312
- reply = client.call('CLUSTER', 'NODES')
312
+ reply = client.call_once('CLUSTER', 'NODES')
313
313
  client.read_timeout = regular_timeout
314
314
  parse_cluster_node_reply(reply)
315
315
  rescue StandardError => e
@@ -33,7 +33,7 @@ class RedisClient
33
33
  raise
34
34
  end
35
35
  rescue ::RedisClient::CommandError => e
36
- @router.renew_cluster_state if e.message.start_with?('CLUSTERDOWN Hash slot not served')
36
+ @router.renew_cluster_state if e.message.start_with?('CLUSTERDOWN')
37
37
  raise
38
38
  end
39
39
  rescue ::RedisClient::ConnectionError
@@ -73,7 +73,7 @@ class RedisClient
73
73
  first_exception ||= result
74
74
  end
75
75
 
76
- stale_cluster_state = true if result.message.start_with?('CLUSTERDOWN Hash slot not served')
76
+ stale_cluster_state = true if result.message.start_with?('CLUSTERDOWN')
77
77
  end
78
78
 
79
79
  results[index] = result
@@ -35,11 +35,15 @@ class RedisClient
35
35
  # Ruby VM allocates 1 MB memory as a stack for a thread.
36
36
  # It is a fixed size but we can modify the size with some environment variables.
37
37
  # So it consumes memory 1 MB multiplied a number of workers.
38
- Thread.new(client, queue) do |pubsub, q|
38
+ Thread.new(client, queue, nil) do |pubsub, q, prev_err|
39
39
  loop do
40
40
  q << pubsub.next_event
41
+ prev_err = nil
41
42
  rescue StandardError => e
43
+ next sleep 0.005 if e.instance_of?(prev_err.class) && e.message == prev_err&.message
44
+
42
45
  q << e
46
+ prev_err = e
43
47
  end
44
48
  end
45
49
  end
@@ -90,11 +94,10 @@ class RedisClient
90
94
 
91
95
  case event = @queue.pop(true)
92
96
  when ::RedisClient::CommandError
93
- raise event unless event.message.start_with?('MOVED', 'CLUSTERDOWN Hash slot not served')
97
+ raise event unless event.message.start_with?('MOVED', 'CLUSTERDOWN')
94
98
 
95
99
  break start_over
96
- when ::RedisClient::ConnectionError
97
- break start_over
100
+ when ::RedisClient::ConnectionError then break start_over
98
101
  when StandardError then raise event
99
102
  when Array then break event
100
103
  end
@@ -161,7 +164,6 @@ class RedisClient
161
164
  @router.renew_cluster_state
162
165
  @state_dict.each_value(&:close)
163
166
  @state_dict.clear
164
- @queue.clear
165
167
  @commands.each { |command| _call(command) }
166
168
  break
167
169
  rescue ::RedisClient::ConnectionError, ::RedisClient::Cluster::NodeMightBeDown
@@ -74,7 +74,7 @@ class RedisClient
74
74
  renew_cluster_state
75
75
  raise
76
76
  rescue ::RedisClient::CommandError => e
77
- renew_cluster_state if e.message.start_with?('CLUSTERDOWN Hash slot not served')
77
+ renew_cluster_state if e.message.start_with?('CLUSTERDOWN')
78
78
  raise
79
79
  rescue ::RedisClient::Cluster::ErrorCollection => e
80
80
  raise if e.errors.any?(::RedisClient::CircuitBreaker::OpenCircuitError)
@@ -82,7 +82,7 @@ class RedisClient
82
82
  renew_cluster_state if e.errors.values.any? do |err|
83
83
  next false if ::RedisClient::Cluster::ErrorIdentification.identifiable?(err) && @node.none? { |c| ::RedisClient::Cluster::ErrorIdentification.client_owns_error?(err, c) }
84
84
 
85
- err.message.start_with?('CLUSTERDOWN Hash slot not served') || err.is_a?(::RedisClient::ConnectionError)
85
+ err.message.start_with?('CLUSTERDOWN') || err.is_a?(::RedisClient::ConnectionError)
86
86
  end
87
87
 
88
88
  raise
@@ -123,7 +123,7 @@ class RedisClient
123
123
  node.call('ASKING')
124
124
  retry
125
125
  end
126
- elsif e.message.start_with?('CLUSTERDOWN Hash slot not served')
126
+ elsif e.message.start_with?('CLUSTERDOWN')
127
127
  renew_cluster_state
128
128
  retry if retry_count >= 0
129
129
  end
@@ -170,7 +170,7 @@ class RedisClient
170
170
  elsif err.message.start_with?('ASK')
171
171
  node = @router.assign_asking_node(err.message)
172
172
  try_asking(node) ? send_transaction(node, redirect: redirect - 1) : err
173
- elsif err.message.start_with?('CLUSTERDOWN Hash slot not served')
173
+ elsif err.message.start_with?('CLUSTERDOWN')
174
174
  @router.renew_cluster_state if @watching_slot.nil?
175
175
  raise err
176
176
  else
@@ -15,10 +15,10 @@ class RedisClient
15
15
 
16
16
  attr_reader :config
17
17
 
18
- def initialize(config, pool: nil, concurrency: nil, **kwargs)
19
- @config = config
18
+ def initialize(config = nil, pool: nil, concurrency: nil, **kwargs)
19
+ @config = config.nil? ? ClusterConfig.new(**kwargs) : config
20
20
  @concurrent_worker = ::RedisClient::Cluster::ConcurrentWorker.create(**(concurrency || {}))
21
- @command_builder = config.command_builder
21
+ @command_builder = @config.command_builder
22
22
 
23
23
  @pool = pool
24
24
  @kwargs = kwargs
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.11.3
4
+ version: 0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-27 00:00:00.000000000 Z
11
+ date: 2024-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client