redis-cluster-client 0.8.0 → 0.8.2
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: 7986c9cc2ea7af5a128397b327e1a4b001740ac6a49af09d8f3ed507665b39d9
|
4
|
+
data.tar.gz: fcb8ef4cbc7095b8b57f9570b24dd4dc4d9b4a517b0e9d2451aa9c740c676989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2624fa1a7ff96f625816beb5f53cac2727c1649f44cb4170f2c744b60f8f4b03eb4ba764cfaba41d867f73807b24965c3fbd2938b3875d0cabf37ccf69bcf32
|
7
|
+
data.tar.gz: b062efff7fea22cda0379c8749c00315d949ad82d491b93307f3c8f42f2af0b563d3af270a1c63bb7b497c9e826f33369618e5dd93fe58415b6097eea9f600b9
|
@@ -4,7 +4,13 @@ class RedisClient
|
|
4
4
|
class Cluster
|
5
5
|
module ErrorIdentification
|
6
6
|
def self.client_owns_error?(err, client)
|
7
|
-
|
7
|
+
return true unless identifiable?(err)
|
8
|
+
|
9
|
+
err.from?(client)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.identifiable?(err)
|
13
|
+
err.is_a?(TaggedError)
|
8
14
|
end
|
9
15
|
|
10
16
|
module TaggedError
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'redis_client'
|
4
4
|
require 'redis_client/config'
|
5
|
-
require 'redis_client/cluster/error_identification'
|
6
5
|
require 'redis_client/cluster/errors'
|
7
6
|
require 'redis_client/cluster/node/primary_only'
|
8
7
|
require 'redis_client/cluster/node/random_replica'
|
@@ -79,11 +78,9 @@ class RedisClient
|
|
79
78
|
end
|
80
79
|
|
81
80
|
class Config < ::RedisClient::Config
|
82
|
-
def initialize(scale_read: false,
|
81
|
+
def initialize(scale_read: false, **kwargs)
|
83
82
|
@scale_read = scale_read
|
84
|
-
|
85
|
-
middlewares.unshift ErrorIdentification::Middleware
|
86
|
-
super(middlewares: middlewares, **kwargs)
|
83
|
+
super(**kwargs)
|
87
84
|
end
|
88
85
|
|
89
86
|
private
|
@@ -109,6 +106,7 @@ class RedisClient
|
|
109
106
|
@topology = klass.new(pool, @concurrent_worker, **kwargs)
|
110
107
|
@config = config
|
111
108
|
@mutex = Mutex.new
|
109
|
+
@last_reloaded_at = nil
|
112
110
|
end
|
113
111
|
|
114
112
|
def inspect
|
@@ -217,10 +215,6 @@ class RedisClient
|
|
217
215
|
end
|
218
216
|
end
|
219
217
|
|
220
|
-
def owns_error?(err)
|
221
|
-
any? { |c| ErrorIdentification.client_owns_error?(err, c) }
|
222
|
-
end
|
223
|
-
|
224
218
|
private
|
225
219
|
|
226
220
|
def make_topology_class(with_replica, replica_affinity)
|
@@ -10,6 +10,7 @@ require 'redis_client/cluster/node_key'
|
|
10
10
|
require 'redis_client/cluster/normalized_cmd_name'
|
11
11
|
require 'redis_client/cluster/transaction'
|
12
12
|
require 'redis_client/cluster/optimistic_locking'
|
13
|
+
require 'redis_client/cluster/error_identification'
|
13
14
|
|
14
15
|
class RedisClient
|
15
16
|
class Cluster
|
@@ -68,7 +69,9 @@ class RedisClient
|
|
68
69
|
raise if e.errors.any?(::RedisClient::CircuitBreaker::OpenCircuitError)
|
69
70
|
|
70
71
|
update_cluster_info! if e.errors.values.any? do |err|
|
71
|
-
|
72
|
+
next false if ::RedisClient::Cluster::ErrorIdentification.identifiable?(err) && @node.none? { |c| ::RedisClient::Cluster::ErrorIdentification.client_owns_error?(err, c) }
|
73
|
+
|
74
|
+
err.message.start_with?('CLUSTERDOWN Hash slot not served')
|
72
75
|
end
|
73
76
|
|
74
77
|
raise
|
@@ -97,7 +100,7 @@ class RedisClient
|
|
97
100
|
rescue ::RedisClient::CircuitBreaker::OpenCircuitError
|
98
101
|
raise
|
99
102
|
rescue ::RedisClient::CommandError => e
|
100
|
-
raise unless ErrorIdentification.client_owns_error?(e, node)
|
103
|
+
raise unless ::RedisClient::Cluster::ErrorIdentification.client_owns_error?(e, node)
|
101
104
|
|
102
105
|
if e.message.start_with?('MOVED')
|
103
106
|
node = assign_redirection_node(e.message)
|
@@ -117,7 +120,7 @@ class RedisClient
|
|
117
120
|
end
|
118
121
|
raise
|
119
122
|
rescue ::RedisClient::ConnectionError => e
|
120
|
-
raise unless ErrorIdentification.client_owns_error?(e, node)
|
123
|
+
raise unless ::RedisClient::Cluster::ErrorIdentification.client_owns_error?(e, node)
|
121
124
|
|
122
125
|
update_cluster_info!
|
123
126
|
|
@@ -8,6 +8,7 @@ class RedisClient
|
|
8
8
|
class Transaction
|
9
9
|
ConsistencyError = Class.new(::RedisClient::Error)
|
10
10
|
MAX_REDIRECTION = 2
|
11
|
+
EMPTY_ARRAY = [].freeze
|
11
12
|
|
12
13
|
def initialize(router, command_builder, node: nil, slot: nil, asking: false)
|
13
14
|
@router = router
|
@@ -62,10 +63,10 @@ class RedisClient
|
|
62
63
|
def execute
|
63
64
|
@pending_commands.each(&:call)
|
64
65
|
|
65
|
-
|
66
|
+
return EMPTY_ARRAY if @pipeline._empty?
|
66
67
|
raise ConsistencyError, "couldn't determine the node: #{@pipeline._commands}" if @node.nil?
|
67
68
|
|
68
|
-
|
69
|
+
commit
|
69
70
|
end
|
70
71
|
|
71
72
|
private
|
@@ -92,8 +93,17 @@ class RedisClient
|
|
92
93
|
@pending_commands.clear
|
93
94
|
end
|
94
95
|
|
95
|
-
def
|
96
|
+
def commit
|
96
97
|
@pipeline.call('EXEC')
|
98
|
+
settle
|
99
|
+
end
|
100
|
+
|
101
|
+
def cancel
|
102
|
+
@pipeline.call('DISCARD')
|
103
|
+
settle
|
104
|
+
end
|
105
|
+
|
106
|
+
def settle
|
97
107
|
# If we needed ASKING on the watch, we need ASKING on the multi as well.
|
98
108
|
@node.call('ASKING') if @asking
|
99
109
|
# Don't handle redirections at this level if we're in a watch (the watcher handles redirections
|
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.8.
|
4
|
+
version: 0.8.2
|
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-04-
|
11
|
+
date: 2024-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|