redis-client 0.18.0 → 0.19.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: '0903a6d92200235e71b687f16de1ec058ca88979a42cc14d2a783ba5d5605061'
4
- data.tar.gz: 1e772676e34700120320659108e1be493cd4d2067a286056cb8ac87f1c3b51e7
3
+ metadata.gz: 1dfa2a6fb000223a3150caeffa1f5341e322b436128dc0cdb0b22998586e1a56
4
+ data.tar.gz: cc8cd32d6036a00710b5d0dc728382c7be48e58fcbc07759d392267cf9a6397b
5
5
  SHA512:
6
- metadata.gz: 66e2d650fe13befeb44b06514e0523d571dfa749f0f787bf7c95126b16d7e54a6b7cb3aa7ed99375f761a302892c2de50c14ad2c011bd42266f4a441a6c9b24b
7
- data.tar.gz: 14b28ce893f07569688acb16a404c2f98bb8cdcd3eaca6d68264a2f1c790cb52c483cd252cc243e8f3f8b4f6e858daf34204d78c7689dcfb2146fc960d45bf3a
6
+ metadata.gz: 69f9ba83f34836944c0af218f1dd117c76d6f4a09a5aeee001727b19ac01013e1bb3ba308386690a34960282153d4075cd7949fc7b0a25c89840b82eceb5dbdf
7
+ data.tar.gz: 54d85162e372c33756adf4af7da1f0abe3d0cd4789336d678a1fc4a37afac749c929d7032a58d3e92f3576ed1001c3ec60bd15670762dc2553a69744891a3b06
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.19.0
4
+
5
+ - Revalidate connection in `RedisClient#connected?`
6
+ - Eagerly fail if `db:` isn't an Integer. #151.
7
+
3
8
  # 0.18.0
4
9
 
5
10
  - Expose more connection details such as `host`, `db`, etc on `RedisClient`.
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ source "https://rubygems.org"
6
6
  gemspec name: "redis-client"
7
7
 
8
8
  gem "minitest"
9
- gem "rake", "~> 13.0"
9
+ gem "rake", "~> 13.1"
10
10
  gem "rake-compiler"
11
11
  gem "rubocop"
12
12
  gem "rubocop-minitest"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.18.0)
4
+ redis-client (0.19.0)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -18,7 +18,7 @@ GEM
18
18
  parser (3.1.2.1)
19
19
  ast (~> 2.4.1)
20
20
  rainbow (3.1.1)
21
- rake (13.0.6)
21
+ rake (13.1.0)
22
22
  rake-compiler (1.2.5)
23
23
  rake
24
24
  redis (4.6.0)
@@ -53,7 +53,7 @@ DEPENDENCIES
53
53
  byebug
54
54
  hiredis
55
55
  minitest
56
- rake (~> 13.0)
56
+ rake (~> 13.1)
57
57
  rake-compiler
58
58
  redis (~> 4.6)
59
59
  redis-client!
@@ -41,7 +41,12 @@ class RedisClient
41
41
  )
42
42
  @username = username
43
43
  @password = password
44
- @db = db || DEFAULT_DB
44
+ @db = begin
45
+ Integer(db || DEFAULT_DB)
46
+ rescue ArgumentError
47
+ raise ArgumentError, "db: must be an Integer, got: #{db.inspect}"
48
+ end
49
+
45
50
  @id = id
46
51
  @ssl = ssl || false
47
52
 
@@ -148,6 +148,7 @@ class RedisClient
148
148
  )
149
149
  true
150
150
  rescue SystemCallError, OpenSSL::SSL::SSLError, SocketError => error
151
+ socket&.close
151
152
  raise CannotConnectError, error.message, error.backtrace
152
153
  end
153
154
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.18.0"
4
+ VERSION = "0.19.0"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -222,17 +222,18 @@ class RedisClient
222
222
 
223
223
  def timeout=(timeout)
224
224
  super
225
- raw_connection.read_timeout = raw_connection.write_timeout = timeout if connected?
225
+ @raw_connection&.read_timeout = timeout
226
+ @raw_connection&.write_timeout = timeout
226
227
  end
227
228
 
228
229
  def read_timeout=(timeout)
229
230
  super
230
- raw_connection.read_timeout = timeout if connected?
231
+ @raw_connection&.read_timeout = timeout
231
232
  end
232
233
 
233
234
  def write_timeout=(timeout)
234
235
  super
235
- raw_connection.write_timeout = timeout if connected?
236
+ @raw_connection&.write_timeout = timeout
236
237
  end
237
238
 
238
239
  def pubsub
@@ -386,7 +387,7 @@ class RedisClient
386
387
  end
387
388
 
388
389
  def connected?
389
- @raw_connection&.connected?
390
+ @raw_connection&.revalidate
390
391
  end
391
392
 
392
393
  def close
@@ -669,6 +670,7 @@ class RedisClient
669
670
  elsif retryable
670
671
  tries = 0
671
672
  connection = nil
673
+ preferred_error = nil
672
674
  begin
673
675
  connection = raw_connection
674
676
  if block_given?
@@ -677,13 +679,15 @@ class RedisClient
677
679
  connection
678
680
  end
679
681
  rescue ConnectionError, ProtocolError => error
682
+ preferred_error ||= error
683
+ preferred_error = error unless error.is_a?(CircuitBreaker::OpenCircuitError)
680
684
  close
681
685
 
682
686
  if !@disable_reconnection && config.retry_connecting?(tries, error)
683
687
  tries += 1
684
688
  retry
685
689
  else
686
- raise
690
+ raise preferred_error
687
691
  end
688
692
  end
689
693
  else
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.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-26 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool