redis-client 0.16.0 → 0.17.1

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: 35ff65a4af6127cb60acff6a3d3b2d2e5e65ddeffc0e8e808b7dec90792697a6
4
- data.tar.gz: 854f82d7548c5462b53ae29a637dc208cdc70b3399b28d0c61f38e02f073e37e
3
+ metadata.gz: 3e73c2e13870d3adcb345e544fe99bbffa6ad1bf5f7267203e49f838c56a7492
4
+ data.tar.gz: d090544eb97a93ad0d21d5a6c14c40ffb3ca384425ccf27d82c797f0f7e2d35a
5
5
  SHA512:
6
- metadata.gz: 2c9e8e564662e86f4e1a24ca9528a5d909a096218eaf62bd7b58838402db390e7bec65d79a43aa89a2b98d22f9645ca7e412ae2db4010dc4131cbf2133d2666f
7
- data.tar.gz: c6400693a10e28e377bf52792ee54f41afb2b2c97ea49578a90eba767b6e3b6a7f37eaeaccf41a38a8222827f461f44aa0b1f75881084dc30a521e407508e277
6
+ metadata.gz: 60e0fbf2c30888ac05855af2ba6b145ac96e0e011cc58d989f66e9379baa549c9af1ad2f7077ce431b334d6b1318b83463eac7bcb7a323752c79644e0dbce495
7
+ data.tar.gz: 1e3e10ef87472a412239261c0642e134f9521e83e49def834bb76b1aa6481c8e8fc9b13cfe1916c0f0ed43af8799a331e9649caa61155ce9eeb8391b0c15c98a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.17.1
4
+
5
+ - Add support for `NaN` in RESP3 protocol doubles.
6
+ This was initially missing from the spec and added about a year ago.
7
+
8
+ # 0.17.0
9
+
10
+ - Adds `sentinel_username` and `sentinel_password` options for `RedisClient#sentinel`
11
+
3
12
  # 0.16.0
4
13
 
5
14
  - Add `RedisClient#disable_reconnection`.
@@ -71,7 +80,7 @@
71
80
 
72
81
  - Make the client resilient to `Timeout.timeout` or `Thread#kill` use (it still is very much discouraged to use either).
73
82
  Use of async interrupts could cause responses to be interleaved.
74
- - hiredis: handle commands returning a top-level `false` (no command does this today, but some extensions might).
83
+ - hiredis: handle commands returning a top-level `false` (no command does this today, but some extensions might).
75
84
  - Workaround a bug in Ruby 2.6 causing a crash if the `debug` gem is enabled when `redis-client` is being required. Fix: #48
76
85
 
77
86
  # 0.8.0
@@ -90,7 +99,7 @@
90
99
 
91
100
  - Raise a distinct `RedisClient::OutOfMemoryError`, for Redis `OOM` errors.
92
101
  - Fix the instrumentation API to be called even for authentication commands.
93
- - Fix `url:` configuration to accept a trailing slash.
102
+ - Fix `url:` configuration to accept a trailing slash.
94
103
 
95
104
  # 0.7.1
96
105
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- redis-client (0.16.0)
4
+ redis-client (0.17.1)
5
5
  connection_pool
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -128,6 +128,41 @@ but a few so that if one is down the client will try the next one. The client
128
128
  is able to remember the last Sentinel that was able to reply correctly and will
129
129
  use it for the next requests.
130
130
 
131
+ To [authenticate](https://redis.io/docs/management/sentinel/#configuring-sentinel-instances-with-authentication) Sentinel itself, you can specify the `sentinel_username` and `sentinel_password` options per instance. Exclude the `sentinel_username` option if you're using password-only authentication.
132
+
133
+ ```ruby
134
+ SENTINELS = [{ host: '127.0.0.1', port: 26380},
135
+ { host: '127.0.0.1', port: 26381}]
136
+
137
+ redis_config = RedisClient.sentinel(name: 'mymaster', sentinel_username: 'appuser', sentinel_password: 'mysecret', sentinels: SENTINELS, role: :master)
138
+ ```
139
+
140
+ If you specify a username and/or password at the top level for your main Redis instance, Sentinel *will not* using thouse credentials
141
+
142
+ ```ruby
143
+ # Use 'mysecret' to authenticate against the mymaster instance, but skip authentication for the sentinels:
144
+ SENTINELS = [{ host: '127.0.0.1', port: 26380 },
145
+ { host: '127.0.0.1', port: 26381 }]
146
+
147
+ redis_config = RedisClient.sentinel(name: 'mymaster', sentinels: SENTINELS, role: :master, password: 'mysecret')
148
+ ```
149
+
150
+ So you have to provide Sentinel credential and Redis explictly even they are the same
151
+
152
+ ```ruby
153
+ # Use 'mysecret' to authenticate against the mymaster instance and sentinel
154
+ SENTINELS = [{ host: '127.0.0.1', port: 26380 },
155
+ { host: '127.0.0.1', port: 26381 }]
156
+
157
+ redis_config = RedisClient.sentinel(name: 'mymaster', sentinels: SENTINELS, role: :master, password: 'mysecret', sentinel_password: 'mysecret')
158
+ ```
159
+
160
+ Also the `name`, `password`, `username` and `db` for Redis instance can be passed as an url:
161
+
162
+ ```ruby
163
+ redis_config = RedisClient.sentinel(url: "redis://appuser:mysecret@mymaster/10", sentinels: SENTINELS, role: :master)
164
+ ```
165
+
131
166
  ### Type support
132
167
 
133
168
  Only a select few Ruby types are supported as arguments beside strings.
@@ -159,21 +159,23 @@ class RedisClient
159
159
  host: nil,
160
160
  port: nil,
161
161
  path: nil,
162
+ username: nil,
163
+ password: nil,
162
164
  **kwargs
163
165
  )
164
166
  if url
165
167
  url_config = URLConfig.new(url)
166
168
  kwargs = {
167
169
  ssl: url_config.ssl?,
168
- username: url_config.username,
169
- password: url_config.password,
170
170
  db: url_config.db,
171
171
  }.compact.merge(kwargs)
172
172
  host ||= url_config.host
173
173
  port ||= url_config.port
174
+ username ||= url_config.username
175
+ password ||= url_config.password
174
176
  end
175
177
 
176
- super(**kwargs)
178
+ super(username: username, password: password, **kwargs)
177
179
 
178
180
  @host = host || DEFAULT_HOST
179
181
  @port = Integer(port || DEFAULT_PORT)
@@ -175,6 +175,8 @@ class RedisClient
175
175
 
176
176
  def parse_double(io)
177
177
  case value = io.gets_chomp
178
+ when "nan"
179
+ Float::NAN
178
180
  when "inf"
179
181
  Float::INFINITY
180
182
  when "-inf"
@@ -9,7 +9,15 @@ class RedisClient
9
9
 
10
10
  attr_reader :name
11
11
 
12
- def initialize(sentinels:, role: :master, name: nil, url: nil, **client_config)
12
+ def initialize(
13
+ sentinels:,
14
+ sentinel_password: nil,
15
+ sentinel_username: nil,
16
+ role: :master,
17
+ name: nil,
18
+ url: nil,
19
+ **client_config
20
+ )
13
21
  unless %i(master replica slave).include?(role.to_sym)
14
22
  raise ArgumentError, "Expected role to be either :master or :replica, got: #{role.inspect}"
15
23
  end
@@ -30,7 +38,11 @@ class RedisClient
30
38
  end
31
39
 
32
40
  @to_list_of_hash = @to_hash = nil
33
- @extra_config = {}
41
+ @extra_config = {
42
+ username: sentinel_username,
43
+ password: sentinel_password,
44
+ db: nil,
45
+ }
34
46
  if client_config[:protocol] == 2
35
47
  @extra_config[:protocol] = client_config[:protocol]
36
48
  @to_list_of_hash = lambda do |may_be_a_list|
@@ -106,9 +118,9 @@ class RedisClient
106
118
  sentinels.map do |sentinel|
107
119
  case sentinel
108
120
  when String
109
- Config.new(**@client_config, **@extra_config, url: sentinel, db: nil)
121
+ Config.new(**@client_config, **@extra_config, url: sentinel)
110
122
  else
111
- Config.new(**@client_config, **@extra_config, **sentinel, db: nil)
123
+ Config.new(**@client_config, **@extra_config, **sentinel)
112
124
  end
113
125
  end
114
126
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisClient
4
- VERSION = "0.16.0"
4
+ VERSION = "0.17.1"
5
5
  end
data/lib/redis_client.rb CHANGED
@@ -175,6 +175,10 @@ class RedisClient
175
175
  "#<#{self.class.name} #{config.server_url}#{id_string}>"
176
176
  end
177
177
 
178
+ def server_url
179
+ config.server_url
180
+ end
181
+
178
182
  def size
179
183
  1
180
184
  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.16.0
4
+ version: 0.17.1
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-08-17 00:00:00.000000000 Z
11
+ date: 2023-10-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.4.10
80
+ rubygems_version: 3.3.7
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Simple low-level client for Redis 6+