redis-client 0.26.2 → 0.26.4

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: f75c9f8b8e4542079642b30d284bd0fbda23d27249e7846bc65c0b002ce61732
4
- data.tar.gz: cdc1d818e27551467b14e53692b5e61da762d1f21de78be00d6650830fdb9d13
3
+ metadata.gz: 154a0c259fc2b3ccd21836d769541db74daef95be9d2e235a36c15b8b6d68d3b
4
+ data.tar.gz: 5f27693c2903da092547ad8f4362a1573e8527d9ef38266074c389574523971b
5
5
  SHA512:
6
- metadata.gz: 15d23f1645fc7bc86c3f58ff0bfebcce62a3aec4783fd5434123277c0445a8d7553fea6f7fc89a36c23c433d7fcd5716b88a79d5131d3a3452d58707e61b965d
7
- data.tar.gz: 7447f4f33e056072445d5d0dad650f3e648af69f1a0690505cb6913d525c32b29f5954349e0ca4852b3bd8d47434ada0e8e1ffde09f8966a664cff08acc5a443
6
+ metadata.gz: ca23aa033f2142cd608cf6197a35b0e32c89f1240344853be148b9eefbec330bbf1a8507277c822482455a8e7198abec888ce73c1f842382d5ebc826c417c5d2
7
+ data.tar.gz: e5f2086185d04e12462dc176a3c90084d7a7b04c520f906dcdb6024a1a42a6d7b418d5c94951628062a746ed0a0426add0970d877587f6b3d25843baf2c0a780
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.26.4
4
+
5
+ - Further improve `rediss://` URLs used with Redis sentinel. Now avoid override explictly set `ssl:` paramter.
6
+ - Fix compatibility with `redis-rb` in sentinel mode.
7
+
8
+ # 0.26.3
9
+
10
+ - Fix `rediss://` (ssl) URLs used with Redis sentinel.
11
+ - Handle Ruby 4.0 connection timeout raising an `IO::Timeout` instead of `Errno::ETIMEDOUT`.
12
+ - Entirely close the connection on authentication failures.
13
+
3
14
  # 0.26.2
4
15
 
5
16
  - Fix compatibility with `connection_pool` version 3+.
@@ -156,7 +156,7 @@ class RedisClient
156
156
  write_timeout: @write_timeout,
157
157
  )
158
158
  true
159
- rescue SystemCallError, OpenSSL::SSL::SSLError, SocketError => error
159
+ rescue SystemCallError, IOError, OpenSSL::SSL::SSLError, SocketError => error
160
160
  socket&.close
161
161
  raise CannotConnectError, error.message, error.backtrace
162
162
  end
@@ -22,12 +22,16 @@ class RedisClient
22
22
  raise ArgumentError, "Expected role to be either :master or :replica, got: #{role.inspect}"
23
23
  end
24
24
 
25
+ # Track whether SSL was explicitly provided by user
26
+ ssl_explicitly_set = client_config.key?(:ssl)
27
+
25
28
  if url
26
29
  url_config = URLConfig.new(url)
27
30
  client_config = {
28
31
  username: url_config.username,
29
32
  password: url_config.password,
30
33
  db: url_config.db,
34
+ ssl: url_config.ssl?,
31
35
  }.compact.merge(client_config)
32
36
  name ||= url_config.host
33
37
  end
@@ -66,6 +70,10 @@ class RedisClient
66
70
 
67
71
  client_config[:reconnect_attempts] ||= DEFAULT_RECONNECT_ATTEMPTS
68
72
  @client_config = client_config || {}
73
+ @sentinel_client_config = @client_config.dup
74
+ # Only remove SSL from sentinel config if it was derived from URL,
75
+ # not if explicitly set by user.
76
+ @sentinel_client_config.delete(:ssl) unless ssl_explicitly_set
69
77
  super(**client_config)
70
78
  @sentinel_configs = sentinels_to_configs(sentinels)
71
79
  end
@@ -133,9 +141,9 @@ class RedisClient
133
141
  sentinels.map do |sentinel|
134
142
  case sentinel
135
143
  when String
136
- Config.new(**@client_config, **@extra_config, url: sentinel)
144
+ Config.new(**@sentinel_client_config, **@extra_config, url: sentinel)
137
145
  else
138
- Config.new(**@client_config, **@extra_config, **sentinel)
146
+ Config.new(**@sentinel_client_config, **@extra_config, **sentinel)
139
147
  end
140
148
  end
141
149
  end
@@ -152,7 +160,7 @@ class RedisClient
152
160
 
153
161
  def resolve_master
154
162
  each_sentinel do |sentinel_client|
155
- host, port = sentinel_client.call("SENTINEL", "get-master-addr-by-name", @name)
163
+ host, port = sentinel_client.call_v(["SENTINEL", "get-master-addr-by-name", @name])
156
164
  next unless host && port
157
165
 
158
166
  refresh_sentinels(sentinel_client)
@@ -171,7 +179,7 @@ class RedisClient
171
179
 
172
180
  def resolve_replica
173
181
  each_sentinel do |sentinel_client|
174
- replicas = sentinel_client.call("SENTINEL", "replicas", @name, &@to_list_of_hash)
182
+ replicas = sentinel_client.call_v(["SENTINEL", "replicas", @name], &@to_list_of_hash)
175
183
  replicas.reject! do |r|
176
184
  flags = r["flags"].to_s.split(",")
177
185
  flags.include?("s_down") || flags.include?("o_down")
@@ -214,7 +222,7 @@ class RedisClient
214
222
  end
215
223
 
216
224
  def refresh_sentinels(sentinel_client)
217
- sentinel_response = sentinel_client.call("SENTINEL", "sentinels", @name, &@to_list_of_hash)
225
+ sentinel_response = sentinel_client.call_v(["SENTINEL", "sentinels", @name], &@to_list_of_hash)
218
226
  sentinels = sentinel_response.map do |sentinel|
219
227
  { host: sentinel.fetch("ip"), port: Integer(sentinel.fetch("port")) }
220
228
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.26.2"
4
+ VERSION = "0.26.4"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -843,13 +843,16 @@ class RedisClient
843
843
  end
844
844
  end
845
845
  rescue FailoverError, CannotConnectError => error
846
+ @raw_connection&.close
846
847
  error._set_config(config)
847
848
  raise error
848
849
  rescue ConnectionError => error
850
+ @raw_connection&.close
849
851
  connect_error = CannotConnectError.with_config(error.message, config)
850
852
  connect_error.set_backtrace(error.backtrace)
851
853
  raise connect_error
852
854
  rescue CommandError => error
855
+ @raw_connection&.close
853
856
  if error.message.match?(/ERR unknown command ['`]HELLO['`]/)
854
857
  raise UnsupportedServer,
855
858
  "redis-client requires Redis 6+ with HELLO command available (#{config.server_url})"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.2
4
+ version: 0.26.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.6.9
73
+ rubygems_version: 4.0.3
74
74
  specification_version: 4
75
75
  summary: Simple low-level client for Redis 6+
76
76
  test_files: []