redis-client 0.23.2 → 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: a3aa8079ed55ab823901c58ee7fc725142ac9f2a964a7db9df9b6eaa8bf3b668
4
- data.tar.gz: 59127fed6458c327bd964a02e7e53de5172ba17eef7fc79b5dcae4a9cf339d6b
3
+ metadata.gz: 7c3cb528ecb15130b80ce97d00a5e0e45c31edfc6147068516e1a52295a94045
4
+ data.tar.gz: b4517fbd99d0f3997e510b6d0d56c345c1fceb1ad44fcac59cceb28faf4326b5
5
5
  SHA512:
6
- metadata.gz: e0cb0139b70d63b59379364699b0ff4a883df931cd8ee60248dd5db23c20c789e752904babce6d48ecd215ef12eae8783c007b85aff1c6cb84057431d3cb1d1e
7
- data.tar.gz: 8fe7a3923239ca5143ac01d1b92e724d6ad3001cdb477032e7ed182358c16b0f38037f2f92e2e0b0f329c97967b477df65a041eace290605734d73dfcc7ab050
6
+ metadata.gz: dbc7fcacc084fcd9d765337ad48a2a8ee413eecfec48f1a166fbd58510299cf92b3e058ce08620055deadeca86464c2c25fe6cddcccab532ab3d2cd741f9cef0
7
+ data.tar.gz: '09164c4ea9f7021d58df97690f78e7940821a44eb7e12cc4c25324bd17e0e784f447443accedbe2299e6d8c0a0a6f15391491465c4c32baaa56286501b77b693'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
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
+
3
8
  # 0.23.2
4
9
 
5
10
  - Fix retry logic not to attempt to retry on an open circuit breaker. Fix #227.
@@ -75,6 +80,7 @@
75
80
  - Discard sockets rather than explictly close them when a fork is detected. #126.
76
81
  - Allow to configure sentinel client via url. #117.
77
82
  - Fix sentinel to preverse the auth/password when refreshing the sentinel list. #107.
83
+ - Added `RedisClient#measure_round_trip_delay` method. #113.
78
84
 
79
85
  # 0.14.1
80
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.2"
4
+ VERSION = "0.24.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.2
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-16 00:00:00.000000000 Z
10
+ date: 2025-03-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: connection_pool