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 +4 -4
- data/CHANGELOG.md +11 -2
- data/Gemfile.lock +1 -1
- data/README.md +35 -0
- data/lib/redis_client/config.rb +5 -3
- data/lib/redis_client/ruby_connection/resp3.rb +2 -0
- data/lib/redis_client/sentinel_config.rb +16 -4
- data/lib/redis_client/version.rb +1 -1
- data/lib/redis_client.rb +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e73c2e13870d3adcb345e544fe99bbffa6ad1bf5f7267203e49f838c56a7492
|
4
|
+
data.tar.gz: d090544eb97a93ad0d21d5a6c14c40ffb3ca384425ccf27d82c797f0f7e2d35a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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.
|
data/lib/redis_client/config.rb
CHANGED
@@ -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)
|
@@ -9,7 +9,15 @@ class RedisClient
|
|
9
9
|
|
10
10
|
attr_reader :name
|
11
11
|
|
12
|
-
def initialize(
|
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
|
121
|
+
Config.new(**@client_config, **@extra_config, url: sentinel)
|
110
122
|
else
|
111
|
-
Config.new(**@client_config, **@extra_config, **sentinel
|
123
|
+
Config.new(**@client_config, **@extra_config, **sentinel)
|
112
124
|
end
|
113
125
|
end
|
114
126
|
end
|
data/lib/redis_client/version.rb
CHANGED
data/lib/redis_client.rb
CHANGED
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.
|
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-
|
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.
|
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+
|