redis-clustering 5.0.8 → 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: bc66b9162a5a533d820c669354314fce36e1f43d9dc5e540861a53930ecbaece
4
- data.tar.gz: 58d71d9ed9c6c175dea6413174d3ea61f48458faba27f0afb55f798f581f7948
3
+ metadata.gz: 48b10241c3e0f41500b8ce224013546591a034dfbc6a0fbbcbb9bef136eeca9e
4
+ data.tar.gz: 7acea63bfa0f3eab6f4c570ddb9a164f6901090964cf5988b54a913e4becc794
5
5
  SHA512:
6
- metadata.gz: b45307adcf1d8396efa2d7b8191e26fe6655bb3251af924cc436a16ba099d4671b7344d9070fd03af3006034de2d56f25828a9290105fdf0b8fe49e8a892949f
7
- data.tar.gz: be694520e18ca77466ebb4cc7b950ef9cd9718d329de04b653597de8ef711730055443dc2d4b3469ec3c3faeca04de750292fd2f1887a06113e28089923c606b
6
+ metadata.gz: b7631f15ef1ce8b13d1af35f98e17f83a27b9dbd80ae8fd95c592010ed0d94dfcb3112bc1aed2e69044d9572e2cc4abe525bb88ae7bc44e72914cb66bb597a10
7
+ data.tar.gz: ce47057bada6b051033e3ca8f9338c62388b0efa530cabf8aca5210243c21deb336a7de459f7c8ce0aa638a0645eb9d1b5ec82edc6075bc73a5670bd67c2107f
@@ -10,8 +10,9 @@ class Redis
10
10
  RedisClient::Cluster::OrchestrationCommandNotSupported => Redis::Cluster::OrchestrationCommandNotSupported,
11
11
  RedisClient::Cluster::AmbiguousNodeError => Redis::Cluster::AmbiguousNodeError,
12
12
  RedisClient::Cluster::ErrorCollection => Redis::Cluster::CommandErrorCollection,
13
- RedisClient::Cluster::Transaction::ConsistencyError => Redis::Cluster::TransactionConsistencyError
14
- ).freeze
13
+ RedisClient::Cluster::Transaction::ConsistencyError => Redis::Cluster::TransactionConsistencyError,
14
+ RedisClient::Cluster::NodeMightBeDown => Redis::Cluster::NodeMightBeDown,
15
+ )
15
16
 
16
17
  class << self
17
18
  def config(**kwargs)
@@ -21,6 +22,29 @@ class Redis
21
22
  def sentinel(**kwargs)
22
23
  super(protocol: 2, **kwargs)
23
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
24
48
  end
25
49
 
26
50
  def initialize(*)
@@ -70,23 +94,16 @@ class Redis
70
94
  handle_errors { super(&block) }
71
95
  end
72
96
 
73
- def multi(&block)
74
- handle_errors { super(&block) }
97
+ def multi(watch: nil, &block)
98
+ handle_errors { super(watch: watch, &block) }
75
99
  end
76
100
 
77
101
  private
78
102
 
79
103
  def handle_errors
80
104
  yield
81
- rescue RedisClient::Cluster::ErrorCollection => error
82
- error.errors.each do |_node, node_error|
83
- if node_error.is_a?(RedisClient::AuthenticationError)
84
- raise ERROR_MAPPING.fetch(node_error.class), node_error.message, node_error.backtrace
85
- end
86
- end
87
- raise ERROR_MAPPING.fetch(error.class), error.message, error.backtrace
88
105
  rescue ::RedisClient::Error => error
89
- raise ERROR_MAPPING.fetch(error.class), error.message, error.backtrace
106
+ Redis::Cluster::Client.translate_error!(error)
90
107
  end
91
108
  end
92
109
  end
data/lib/redis/cluster.rb CHANGED
@@ -41,6 +41,9 @@ class Redis
41
41
  class TransactionConsistencyError < BaseError
42
42
  end
43
43
 
44
+ class NodeMightBeDown < BaseError
45
+ end
46
+
44
47
  def connection
45
48
  raise NotImplementedError, "Redis::Cluster doesn't implement #connection"
46
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.8
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-10-23 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,14 +24,14 @@ dependencies:
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 5.0.8
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.8
34
+ version: 5.1.0
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: redis-cluster-client
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -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.8
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.8/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: