redis-clustering 5.0.7 → 5.1.0

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: 06c77b6a607098a0fe869f6cd243da1751b964be61972881ab5b07b83763f776
4
- data.tar.gz: 964e18a67593790e58dd1300474d6b384190cff5875e34a00e986d69bed64e6a
3
+ metadata.gz: 48b10241c3e0f41500b8ce224013546591a034dfbc6a0fbbcbb9bef136eeca9e
4
+ data.tar.gz: 7acea63bfa0f3eab6f4c570ddb9a164f6901090964cf5988b54a913e4becc794
5
5
  SHA512:
6
- metadata.gz: ba01fc739cfc44fcafe6fcbe33a43801cb30e536adb199f56a6a67a0e6afd44d9fdeeea4cb8cd622b369e4fbcc8edc7269717ca3625cc0fad307888c8e7d21e2
7
- data.tar.gz: 5f92a9ece6a5ea63ffc66f02b9a7909b05ff53e393850689220a31f286d099cae9d34275b95456f1cd58e5dee951a49191f7d2a783354ea99fbc2322d4548ae4
6
+ metadata.gz: b7631f15ef1ce8b13d1af35f98e17f83a27b9dbd80ae8fd95c592010ed0d94dfcb3112bc1aed2e69044d9572e2cc4abe525bb88ae7bc44e72914cb66bb597a10
7
+ data.tar.gz: ce47057bada6b051033e3ca8f9338c62388b0efa530cabf8aca5210243c21deb336a7de459f7c8ce0aa638a0645eb9d1b5ec82edc6075bc73a5670bd67c2107f
@@ -9,8 +9,10 @@ class Redis
9
9
  RedisClient::Cluster::InitialSetupError => Redis::Cluster::InitialSetupError,
10
10
  RedisClient::Cluster::OrchestrationCommandNotSupported => Redis::Cluster::OrchestrationCommandNotSupported,
11
11
  RedisClient::Cluster::AmbiguousNodeError => Redis::Cluster::AmbiguousNodeError,
12
- RedisClient::Cluster::ErrorCollection => Redis::Cluster::CommandErrorCollection
13
- ).freeze
12
+ RedisClient::Cluster::ErrorCollection => Redis::Cluster::CommandErrorCollection,
13
+ RedisClient::Cluster::Transaction::ConsistencyError => Redis::Cluster::TransactionConsistencyError,
14
+ RedisClient::Cluster::NodeMightBeDown => Redis::Cluster::NodeMightBeDown,
15
+ )
14
16
 
15
17
  class << self
16
18
  def config(**kwargs)
@@ -20,6 +22,29 @@ class Redis
20
22
  def sentinel(**kwargs)
21
23
  super(protocol: 2, **kwargs)
22
24
  end
25
+
26
+ def translate_error!(error, mapping: ERROR_MAPPING)
27
+ case error
28
+ when RedisClient::Cluster::ErrorCollection
29
+ error.errors.each do |_node, node_error|
30
+ if node_error.is_a?(RedisClient::AuthenticationError)
31
+ raise mapping.fetch(node_error.class), node_error.message, node_error.backtrace
32
+ end
33
+ end
34
+
35
+ remapped_node_errors = error.errors.map do |node_key, node_error|
36
+ remapped = mapping.fetch(node_error.class, node_error.class).new(node_error.message)
37
+ remapped.set_backtrace node_error.backtrace
38
+ [node_key, remapped]
39
+ end.to_h
40
+
41
+ raise(Redis::Cluster::CommandErrorCollection.new(remapped_node_errors, error.message).tap do |remapped|
42
+ remapped.set_backtrace error.backtrace
43
+ end)
44
+ else
45
+ Redis::Client.translate_error!(error, mapping: mapping)
46
+ end
47
+ end
23
48
  end
24
49
 
25
50
  def initialize(*)
@@ -28,11 +53,11 @@ class Redis
28
53
  ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)
29
54
 
30
55
  def id
31
- @router.node.node_keys.join(' ')
56
+ @router.node_keys.join(' ')
32
57
  end
33
58
 
34
59
  def server_url
35
- @router.node.node_keys
60
+ @router.node_keys
36
61
  end
37
62
 
38
63
  def connected?
@@ -69,23 +94,16 @@ class Redis
69
94
  handle_errors { super(&block) }
70
95
  end
71
96
 
72
- def multi(&block)
73
- handle_errors { super(&block) }
97
+ def multi(watch: nil, &block)
98
+ handle_errors { super(watch: watch, &block) }
74
99
  end
75
100
 
76
101
  private
77
102
 
78
103
  def handle_errors
79
104
  yield
80
- rescue RedisClient::Cluster::ErrorCollection => error
81
- error.errors.each do |_node, node_error|
82
- if node_error.is_a?(RedisClient::AuthenticationError)
83
- raise ERROR_MAPPING.fetch(node_error.class), node_error.message, node_error.backtrace
84
- end
85
- end
86
- raise ERROR_MAPPING.fetch(error.class), error.message, error.backtrace
87
105
  rescue ::RedisClient::Error => error
88
- raise ERROR_MAPPING.fetch(error.class), error.message, error.backtrace
106
+ Redis::Cluster::Client.translate_error!(error)
89
107
  end
90
108
  end
91
109
  end
data/lib/redis/cluster.rb CHANGED
@@ -38,6 +38,12 @@ class Redis
38
38
  class AmbiguousNodeError < BaseError
39
39
  end
40
40
 
41
+ class TransactionConsistencyError < BaseError
42
+ end
43
+
44
+ class NodeMightBeDown < BaseError
45
+ end
46
+
41
47
  def connection
42
48
  raise NotImplementedError, "Redis::Cluster doesn't implement #connection"
43
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-clustering
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.7
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezra Zygmuntowicz
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2023-08-09 00:00:00.000000000 Z
19
+ date: 2024-02-09 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: redis
@@ -24,28 +24,28 @@ dependencies:
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 5.0.7
27
+ version: 5.1.0
28
28
  type: :runtime
29
29
  prerelease: false
30
30
  version_requirements: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 5.0.7
34
+ version: 5.1.0
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: redis-cluster-client
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 0.3.7
41
+ version: 0.7.0
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 0.3.7
48
+ version: 0.7.0
49
49
  description: |2
50
50
  A Ruby client that tries to match Redis' Cluster API one-to-one, while still
51
51
  providing an idiomatic interface.
@@ -68,9 +68,9 @@ licenses:
68
68
  metadata:
69
69
  bug_tracker_uri: https://github.com/redis/redis-rb/issues
70
70
  changelog_uri: https://github.com/redis/redis-rb/blob/master/cluster/CHANGELOG.md
71
- documentation_uri: https://www.rubydoc.info/gems/redis/5.0.7
71
+ documentation_uri: https://www.rubydoc.info/gems/redis/5.1.0
72
72
  homepage_uri: https://github.com/redis/redis-rb/blob/master/cluster
73
- source_code_uri: https://github.com/redis/redis-rb/tree/v5.0.7/cluster
73
+ source_code_uri: https://github.com/redis/redis-rb/tree/v5.1.0/cluster
74
74
  post_install_message:
75
75
  rdoc_options: []
76
76
  require_paths: