redis-client 0.11.0 → 0.11.2

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: 7f28d878a923f684e1ddade2a735339dc7ae55d3091b3d21b812fcf1b232b8fe
4
- data.tar.gz: 5cc874fa373695185c4b5f040e8368be66550596838faadab8b3e57e45f8c0b0
3
+ metadata.gz: 24ef1685664b6af416108d0994b89e1c8d70e3ba1e5d17363f9bc92a0a34137f
4
+ data.tar.gz: 065e1efd905230b129fe0e82569ae4691644c2126c507eb8e9c44fec556e6584
5
5
  SHA512:
6
- metadata.gz: ba5313f360e675d1e751f6c5138290facab7e3ea043d5328b14556050ceb44155947ad670077e22b1fb04b2aa5738a6d6b77454b5d31e0a4641c1e705f3ba545
7
- data.tar.gz: 45463aae9b8d188cc5d1a2c0604962001bafcd266fb526fecb7ddee5081fbc28a9a5a27b8a09525b515d69266cf7740424a50408e62cf2361debe1ffb52b3d9e
6
+ metadata.gz: 4f1b143a96e5c5d7f96919187e8a7d7b481da1661d19044c4b699cad713761fcf371b5733ab5200d05e176f782318c6fe23a73568eeb6f610a061a97f1706181
7
+ data.tar.gz: b97603e2d45b1008b4920a9576315809f7d41de0cd95f05f2c2a1e1241e3e9bbdf3d57c80afc15cc823d795bb41686ad079f7cb27b203cd03d884291a165787a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.11.2
4
+
5
+ - Close connection on READONLY errors. Fix: #64
6
+ - Handle Redis 6+ servers with a missing HELLO command. See: #67
7
+ - Validate `url` parameters a bit more strictly. Fix #61
8
+
9
+ # 0.11.1
10
+
11
+ - hiredis: Workaround a compilation bug with Xcode 14.0. Fix: #58
12
+ - Accept `URI` instances as `uri` parameter.
13
+
3
14
  # 0.11.0
4
15
 
5
16
  - hiredis: do not eagerly close the connection on read timeout, let the caller decide if a timeout is final.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.11.0)
4
+ redis-client (0.11.2)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -154,7 +154,11 @@ class RedisClient
154
154
  **kwargs
155
155
  )
156
156
  if url
157
- uri = URI.parse(url)
157
+ uri = URI(url)
158
+ unless uri.scheme == "redis" || uri.scheme == "rediss"
159
+ raise ArgumentError, "Invalid URL: #{url.inspect}"
160
+ end
161
+
158
162
  kwargs[:ssl] = uri.scheme == "rediss" unless kwargs.key?(:ssl)
159
163
 
160
164
  kwargs[:username] ||= uri.user if uri.password && !uri.user.empty?
@@ -17,7 +17,7 @@ class RedisClient
17
17
  write(command)
18
18
  result = read(timeout)
19
19
  @pending_reads -= 1
20
- if result.is_a?(CommandError)
20
+ if result.is_a?(Error)
21
21
  result._set_command(command)
22
22
  raise result
23
23
  else
@@ -37,7 +37,7 @@ class RedisClient
37
37
  timeout = timeouts && timeouts[index]
38
38
  result = read(timeout)
39
39
  @pending_reads -= 1
40
- if result.is_a?(CommandError)
40
+ if result.is_a?(Error)
41
41
  result._set_command(commands[index])
42
42
  exception ||= result
43
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.11.0"
4
+ VERSION = "0.11.2"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -90,9 +90,17 @@ class RedisClient
90
90
  WriteTimeoutError = Class.new(TimeoutError)
91
91
  CheckoutTimeoutError = Class.new(TimeoutError)
92
92
 
93
- class CommandError < Error
93
+ module HasCommand
94
94
  attr_reader :command
95
95
 
96
+ def _set_command(command)
97
+ @command = command
98
+ end
99
+ end
100
+
101
+ class CommandError < Error
102
+ include HasCommand
103
+
96
104
  class << self
97
105
  def parse(error_message)
98
106
  code = if error_message.start_with?("ERR Error running script")
@@ -107,18 +115,16 @@ class RedisClient
107
115
  klass.new(error_message)
108
116
  end
109
117
  end
110
-
111
- def _set_command(command)
112
- @command = command
113
- end
114
118
  end
115
119
 
116
120
  AuthenticationError = Class.new(CommandError)
117
121
  PermissionError = Class.new(CommandError)
118
- ReadOnlyError = Class.new(CommandError)
119
122
  WrongTypeError = Class.new(CommandError)
120
123
  OutOfMemoryError = Class.new(CommandError)
121
124
 
125
+ ReadOnlyError = Class.new(ConnectionError)
126
+ ReadOnlyError.include(HasCommand)
127
+
122
128
  CommandError::ERRORS = {
123
129
  "WRONGPASS" => AuthenticationError,
124
130
  "NOPERM" => PermissionError,
@@ -686,9 +692,9 @@ class RedisClient
686
692
  rescue ConnectionError => error
687
693
  raise CannotConnectError, error.message, error.backtrace
688
694
  rescue CommandError => error
689
- if error.message.include?("ERR unknown command `HELLO`")
695
+ if error.message.match?(/ERR unknown command ['`]HELLO['`]/)
690
696
  raise UnsupportedServer,
691
- "Your Redis server version is too old. redis-client requires Redis 6+. (#{config.server_url})"
697
+ "redis-client requires Redis 6+ with HELLO command available (#{config.server_url})"
692
698
  else
693
699
  raise
694
700
  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.11.0
4
+ version: 0.11.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: 2022-11-01 00:00:00.000000000 Z
11
+ date: 2022-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool