redis-client 0.23.0 → 0.24.0

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: 588c7b4963a757c4d297236e15e0fd2b84d1137f42f14ca26dcfdf3349588126
4
- data.tar.gz: cc68ebf122ca5c9044c9c0e08713071e60b151c526f37699d7fa5d28c2e52e5f
3
+ metadata.gz: 7c3cb528ecb15130b80ce97d00a5e0e45c31edfc6147068516e1a52295a94045
4
+ data.tar.gz: b4517fbd99d0f3997e510b6d0d56c345c1fceb1ad44fcac59cceb28faf4326b5
5
5
  SHA512:
6
- metadata.gz: 3a23804a8dbf13a35f8dae709586c44b3b81bd4d6d671ed79890b734b9e722f996c6d514bc609da511a0695deeefbfdfafcf8545fd6a0f7d8144d1936f72f417
7
- data.tar.gz: 1be3aff9e63209a7424c0078f1fe26d8f45212034f0a8d18fa8cb778f7bdb12200effa4796082dd7a1096f18f840cdf84ddff8a9ab3ff2ad6a552db9db595484
6
+ metadata.gz: dbc7fcacc084fcd9d765337ad48a2a8ee413eecfec48f1a166fbd58510299cf92b3e058ce08620055deadeca86464c2c25fe6cddcccab532ab3d2cd741f9cef0
7
+ data.tar.gz: '09164c4ea9f7021d58df97690f78e7940821a44eb7e12cc4c25324bd17e0e784f447443accedbe2299e6d8c0a0a6f15391491465c4c32baaa56286501b77b693'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.24.0
4
+
5
+ - Allow `sentinel_password` to be provided as a `Proc`.
6
+ - Ensure `Config#inspect` and `Config#to_s` do not display stored passwords.
7
+
8
+ # 0.23.2
9
+
10
+ - Fix retry logic not to attempt to retry on an open circuit breaker. Fix #227.
11
+
12
+ # 0.23.1
13
+
14
+ - Fix a potential crash in `hiredis-client` when using subcriptions (`next_event`). See #221.
15
+
3
16
  # 0.23.0
4
17
 
5
18
  - Allow `password` to be a callable. Makes it easy to implement short lived password authentication strategies.
@@ -67,6 +80,7 @@
67
80
  - Discard sockets rather than explictly close them when a fork is detected. #126.
68
81
  - Allow to configure sentinel client via url. #117.
69
82
  - Fix sentinel to preverse the auth/password when refreshing the sentinel list. #107.
83
+ - Added `RedisClient#measure_round_trip_delay` method. #113.
70
84
 
71
85
  # 0.14.1
72
86
 
@@ -40,7 +40,7 @@ class RedisClient
40
40
  circuit_breaker: nil
41
41
  )
42
42
  @username = username
43
- @password = password
43
+ @password = password && !password.respond_to?(:call) ? ->(_) { password } : password
44
44
  @db = begin
45
45
  Integer(db || DEFAULT_DB)
46
46
  rescue ArgumentError
@@ -70,7 +70,6 @@ class RedisClient
70
70
 
71
71
  reconnect_attempts = Array.new(reconnect_attempts, 0).freeze if reconnect_attempts.is_a?(Integer)
72
72
  @reconnect_attempts = reconnect_attempts
73
- @connection_prelude = (build_connection_prelude unless @password.respond_to?(:call))
74
73
 
75
74
  circuit_breaker = CircuitBreaker.new(**circuit_breaker) if circuit_breaker.is_a?(Hash)
76
75
  if @circuit_breaker = circuit_breaker
@@ -88,19 +87,36 @@ class RedisClient
88
87
  end
89
88
 
90
89
  def connection_prelude
91
- if @password.respond_to?(:call)
92
- build_connection_prelude
93
- else
94
- @connection_prelude
90
+ prelude = []
91
+ pass = password
92
+ if protocol == 3
93
+ prelude << if pass
94
+ ["HELLO", "3", "AUTH", username, pass]
95
+ else
96
+ ["HELLO", "3"]
97
+ end
98
+ elsif pass
99
+ prelude << if @username && !@username.empty?
100
+ ["AUTH", @username, pass]
101
+ else
102
+ ["AUTH", pass]
103
+ end
95
104
  end
105
+
106
+ if @db && @db != 0
107
+ prelude << ["SELECT", @db.to_s]
108
+ end
109
+
110
+ # Deep freeze all the strings and commands
111
+ prelude.map! do |commands|
112
+ commands = commands.map { |str| str.frozen? ? str : str.dup.freeze }
113
+ commands.freeze
114
+ end
115
+ prelude.freeze
96
116
  end
97
117
 
98
118
  def password
99
- if @password.respond_to?(:call)
100
- @password.call(username)
101
- else
102
- @password
103
- end
119
+ @password&.call(username)
104
120
  end
105
121
 
106
122
  def username
@@ -162,37 +178,6 @@ class RedisClient
162
178
  end
163
179
  url
164
180
  end
165
-
166
- private
167
-
168
- def build_connection_prelude
169
- prelude = []
170
- pass = password
171
- if protocol == 3
172
- prelude << if pass
173
- ["HELLO", "3", "AUTH", username, pass]
174
- else
175
- ["HELLO", "3"]
176
- end
177
- elsif pass
178
- prelude << if @username && !@username.empty?
179
- ["AUTH", @username, pass]
180
- else
181
- ["AUTH", pass]
182
- end
183
- end
184
-
185
- if @db && @db != 0
186
- prelude << ["SELECT", @db.to_s]
187
- end
188
-
189
- # Deep freeze all the strings and commands
190
- prelude.map! do |commands|
191
- commands = commands.map { |str| str.frozen? ? str : str.dup.freeze }
192
- commands.freeze
193
- end
194
- prelude.freeze
195
- end
196
181
  end
197
182
 
198
183
  include Common
@@ -38,9 +38,14 @@ class RedisClient
38
38
  end
39
39
 
40
40
  @to_list_of_hash = @to_hash = nil
41
+ password = if sentinel_password && !sentinel_password.respond_to?(:call)
42
+ ->(_) { sentinel_password }
43
+ else
44
+ sentinel_password
45
+ end
41
46
  @extra_config = {
42
47
  username: sentinel_username,
43
- password: sentinel_password,
48
+ password: password,
44
49
  db: nil,
45
50
  }
46
51
  if client_config[:protocol] == 2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.23.0"
4
+ VERSION = "0.24.0"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -710,9 +710,14 @@ class RedisClient
710
710
  end
711
711
  rescue ConnectionError, ProtocolError => error
712
712
  preferred_error ||= error
713
- preferred_error = error unless error.is_a?(CircuitBreaker::OpenCircuitError)
714
713
  close
715
714
 
715
+ if error.is_a?(CircuitBreaker::OpenCircuitError)
716
+ raise preferred_error
717
+ else
718
+ preferred_error = error
719
+ end
720
+
716
721
  if !@disable_reconnection && config.retry_connecting?(tries, error)
717
722
  tries += 1
718
723
  retry
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-10 00:00:00.000000000 Z
10
+ date: 2025-03-05 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: connection_pool
@@ -24,7 +23,6 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
27
- description:
28
26
  email:
29
27
  - jean.boussier@gmail.com
30
28
  executables: []
@@ -58,7 +56,6 @@ metadata:
58
56
  homepage_uri: https://github.com/redis-rb/redis-client
59
57
  source_code_uri: https://github.com/redis-rb/redis-client
60
58
  changelog_uri: https://github.com/redis-rb/redis-client/blob/master/CHANGELOG.md
61
- post_install_message:
62
59
  rdoc_options: []
63
60
  require_paths:
64
61
  - lib
@@ -73,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
70
  - !ruby/object:Gem::Version
74
71
  version: '0'
75
72
  requirements: []
76
- rubygems_version: 3.0.3.1
77
- signing_key:
73
+ rubygems_version: 3.6.2
78
74
  specification_version: 4
79
75
  summary: Simple low-level client for Redis 6+
80
76
  test_files: []