redis-clustering 5.0.8 → 5.2.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: '0390ca44d9f71661f4cfb1a7f8d1a396a84e204e992cf8a5d0755af4232cb7ac'
4
+ data.tar.gz: 923cffa3fc0a5a2aaecb4d669ea685e25047c7dc70f932f3e807e6e381fc3ecb
5
5
  SHA512:
6
- metadata.gz: b45307adcf1d8396efa2d7b8191e26fe6655bb3251af924cc436a16ba099d4671b7344d9070fd03af3006034de2d56f25828a9290105fdf0b8fe49e8a892949f
7
- data.tar.gz: be694520e18ca77466ebb4cc7b950ef9cd9718d329de04b653597de8ef711730055443dc2d4b3469ec3c3faeca04de750292fd2f1887a06113e28089923c606b
6
+ metadata.gz: b4c5f9903044360cd0317a2ad75d0c41cbd8627c34da86c9cca3471ef78e0256778c15f997f0073386b8dbfa38ca906ab03b31efb3b7c190b7412a0d6bdd1987
7
+ data.tar.gz: 4e331655c8142429b1fbee72eec3c1fd26b42f5fa4e33156a0f3415151bd7bc3b9da85e604d464b4db33c2425d6a2b910718a6b6108ede5e7bc30635371ea33f
@@ -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(*)
@@ -66,27 +90,20 @@ class Redis
66
90
  handle_errors { super(timeout, command, &block) }
67
91
  end
68
92
 
69
- def pipelined(&block)
70
- handle_errors { super(&block) }
93
+ def pipelined(exception: true, &block)
94
+ handle_errors { super(exception: exception, &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
@@ -93,6 +96,10 @@ class Redis
93
96
  send_command([:cluster, subcommand] + args, &block)
94
97
  end
95
98
 
99
+ def watch(*keys, &block)
100
+ synchronize { |c| c.call_v([:watch] + keys, &block) }
101
+ end
102
+
96
103
  private
97
104
 
98
105
  def initialize_client(options)
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.2.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-04-15 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.8
27
+ version: 5.2.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.2.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.7.0
41
+ version: 0.7.11
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.7.0
48
+ version: 0.7.11
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.8
71
+ documentation_uri: https://www.rubydoc.info/gems/redis/5.2.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.2.0/cluster
74
74
  post_install_message:
75
75
  rdoc_options: []
76
76
  require_paths:
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.3.7
89
+ rubygems_version: 3.5.3
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: A Ruby client library for Redis Cluster