redis-client 0.22.0 → 0.22.2

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: 6471d100e48137355f30f150526beba636372c0a8ab89b1d05c9870f156bd01c
4
- data.tar.gz: 6c5a17e18eabfdb54e500a1f8deec09dbe1aba9234214e34f0ade2fea170b669
3
+ metadata.gz: 796fe04bd550f92d5bf2656a62de54caf1f640b45ab5d5f51fed61d0b61ee883
4
+ data.tar.gz: 4b34ce4e0ed5a2d4816863970789e7c23ce53fe8a561718b78b79432d09e3fe8
5
5
  SHA512:
6
- metadata.gz: 7b2253e3c62b2cdce341b210ceeebb25f37484161a356c3982d747884870acb040d071471ca50d0abac605a9e759a89d678fbaf19fd1a21cf0b2bfe3c5fd2472
7
- data.tar.gz: 8b44296f79fa5591b5776ca6a236b1d2cbce76f9f56a008ab564d2ae8381b1da66385c74f0fe7c00d244bd418f1f7e564b8c198ade7c43588f45e25caa94581e
6
+ metadata.gz: d9dfb29603171606e71daaa43474812790988876720dd254a0069fc429ba035ede74b1b19d243967b9adb61c0d48ab4aa2931ef188cd2bb17d820b480967c897
7
+ data.tar.gz: e6ff3a4543991e139a26f8fa4bdb714aafe83678490f9890ca5fd0ec1a95bdddd0c8fec57dcb4ff88fb28a19d577a556172cb39e4bd4f290d41c6871de43345b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.22.2
4
+
5
+ - Fix the sentinel client to properly extend timeout for blocking commands.
6
+ - Fix IPv6 support in `RedisClient::Config#server_url`.
7
+
8
+ # 0.22.1
9
+
10
+ - Fix `ProtocolError: Unknown sigil type` errors when using SSL connection. See #190.
11
+
3
12
  # 0.22.0
4
13
 
5
14
  - Made various performance optimizations to the Ruby driver. See #184.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.22.0)
4
+ redis-client (0.22.2)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -15,7 +15,7 @@ GEM
15
15
  hiredis (0.6.3-java)
16
16
  json (2.7.1)
17
17
  json (2.7.1-java)
18
- minitest (5.22.3)
18
+ minitest (5.23.0)
19
19
  parallel (1.24.0)
20
20
  parser (3.3.0.5)
21
21
  ast (~> 2.4.1)
data/README.md CHANGED
@@ -149,7 +149,7 @@ SENTINELS = [{ host: '127.0.0.1', port: 26380 },
149
149
  redis_config = RedisClient.sentinel(name: 'mymaster', sentinels: SENTINELS, role: :master, password: 'mysecret')
150
150
  ```
151
151
 
152
- So you have to provide Sentinel credential and Redis explictly even they are the same
152
+ So you have to provide Sentinel credential and Redis explicitly even they are the same
153
153
 
154
154
  ```ruby
155
155
  # Use 'mysecret' to authenticate against the mymaster instance and sentinel
@@ -524,7 +524,7 @@ recover for a while.
524
524
 
525
525
  [Circuit breakers are a pattern that does exactly that](https://en.wikipedia.org/wiki/Circuit_breaker_design_pattern).
526
526
 
527
- Configuation options:
527
+ Configuration options:
528
528
 
529
529
  - `error_threshold`. The amount of errors to encounter within `error_threshold_timeout` amount of time before opening the circuit, that is to start rejecting requests instantly.
530
530
  - `error_threshold_timeout`. The amount of time in seconds that `error_threshold` errors must occur to open the circuit. Defaults to `error_timeout` seconds if not set.
@@ -133,7 +133,13 @@ class RedisClient
133
133
  url = "#{url}?db=#{db}"
134
134
  end
135
135
  else
136
- url = "redis#{'s' if ssl?}://#{host}:#{port}"
136
+ # add brackets to IPv6 address
137
+ redis_host = if host.count(":") >= 2
138
+ "[#{host}]"
139
+ else
140
+ host
141
+ end
142
+ url = "redis#{'s' if ssl?}://#{redis_host}:#{port}"
137
143
  if db != 0
138
144
  url = "#{url}/#{db}"
139
145
  end
@@ -28,7 +28,7 @@ class RedisClient
28
28
  def call(command, timeout)
29
29
  @pending_reads += 1
30
30
  write(command)
31
- result = read(timeout)
31
+ result = read(connection_timeout(timeout))
32
32
  @pending_reads -= 1
33
33
  if result.is_a?(Error)
34
34
  result._set_command(command)
@@ -49,7 +49,7 @@ class RedisClient
49
49
 
50
50
  size.times do |index|
51
51
  timeout = timeouts && timeouts[index]
52
- result = read(timeout)
52
+ result = read(connection_timeout(timeout))
53
53
  @pending_reads -= 1
54
54
 
55
55
  # A multi/exec command can return an array of results.
@@ -73,5 +73,14 @@ class RedisClient
73
73
  results
74
74
  end
75
75
  end
76
+
77
+ def connection_timeout(timeout)
78
+ return timeout unless timeout && timeout > 0
79
+
80
+ # Can't use the command timeout argument as the connection timeout
81
+ # otherwise it would be very racy. So we add the regular read_timeout on top
82
+ # to account for the network delay.
83
+ timeout + config.read_timeout
84
+ end
76
85
  end
77
86
  end
@@ -190,7 +190,8 @@ class RedisClient
190
190
 
191
191
  def fill_buffer(strict, size = @chunk_size)
192
192
  remaining = size
193
- start = @offset - @buffer.bytesize
193
+ buffer_size = @buffer.bytesize
194
+ start = @offset - buffer_size
194
195
  empty_buffer = start >= 0
195
196
 
196
197
  loop do
@@ -199,12 +200,27 @@ class RedisClient
199
200
  else
200
201
  @io.read_nonblock([remaining, @chunk_size].max, exception: false)
201
202
  end
203
+
202
204
  case bytes
203
205
  when :wait_readable
206
+ # Ref: https://github.com/redis-rb/redis-client/issues/190
207
+ # SSLSocket always clear the provided buffer, even when it didn't
208
+ # read anything. So we need to reset the offset accordingly.
209
+ if empty_buffer && @buffer.empty?
210
+ @offset -= buffer_size
211
+ end
212
+
204
213
  unless @io.to_io.wait_readable(@read_timeout)
205
214
  raise ReadTimeoutError, "Waited #{@read_timeout} seconds" unless @blocking_reads
206
215
  end
207
216
  when :wait_writable
217
+ # Ref: https://github.com/redis-rb/redis-client/issues/190
218
+ # SSLSocket always clear the provided buffer, even when it didn't
219
+ # read anything. So we need to reset the offset accordingly.
220
+ if empty_buffer && @buffer.empty?
221
+ @offset -= buffer_size
222
+ end
223
+
208
224
  @io.to_io.wait_writable(@write_timeout) or raise(WriteTimeoutError, "Waited #{@write_timeout} seconds")
209
225
  when nil
210
226
  raise EOFError
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.22.0"
4
+ VERSION = "0.22.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-12 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.5.5
80
+ rubygems_version: 3.5.9
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Simple low-level client for Redis 6+