redis-client 0.11.1 → 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: ded07d814692a3e286f61a38a3d8129ef35189659124e73fd3e24e4e53a6a08b
4
- data.tar.gz: 021c3dc9bf79717313a9f41e6bc29973cafbfe08ba15b2eb2b8560228939752b
3
+ metadata.gz: 24ef1685664b6af416108d0994b89e1c8d70e3ba1e5d17363f9bc92a0a34137f
4
+ data.tar.gz: 065e1efd905230b129fe0e82569ae4691644c2126c507eb8e9c44fec556e6584
5
5
  SHA512:
6
- metadata.gz: 52ebda137196361b56487d014cdbf5f188cd8822d92f955aeb39ee9fdea448051e38be2e68bf60616cdbeec1df942c25472a5d71e6b6c139ef96b1286db94d32
7
- data.tar.gz: 495caeef04270d289eb58a5a1f0f52f19414db8d3efa0554edea041d165a3e14a33337156fa28c55c56fbee29b5683347d871fb7f84f79fea02371d1e0f605ce
6
+ metadata.gz: 4f1b143a96e5c5d7f96919187e8a7d7b481da1661d19044c4b699cad713761fcf371b5733ab5200d05e176f782318c6fe23a73568eeb6f610a061a97f1706181
7
+ data.tar.gz: b97603e2d45b1008b4920a9576315809f7d41de0cd95f05f2c2a1e1241e3e9bbdf3d57c80afc15cc823d795bb41686ad079f7cb27b203cd03d884291a165787a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Unreleased
2
2
 
3
- - hiredis: Workaround a compilation bug with Xcode 14.0, Fix: #58
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
4
12
  - Accept `URI` instances as `uri` parameter.
5
13
 
6
14
  # 0.11.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.11.1)
4
+ redis-client (0.11.2)
5
5
  connection_pool
6
6
 
7
7
  GEM
@@ -155,6 +155,10 @@ class RedisClient
155
155
  )
156
156
  if url
157
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.1"
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.1
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-04 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