redis-client 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -2
- data/Gemfile.lock +1 -1
- data/README.md +35 -0
- data/lib/redis_client/config.rb +5 -3
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8038f4b1f7316e16bd3561f43311334a9e69896e54a75b1a9666cb2718ba3b0
|
4
|
+
data.tar.gz: e37514256b44be8b0d5832c3d944c8d3be2a8228bff1fa05ac3a28347c6445ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f02d99ca8c468cf38a4527817257169104d7f64cea5110c170d434d82b7f30cfea8338e0e746504d2d8c29866f81ef6cf4e81d014400ff364d5138d7653dfdc3
|
7
|
+
data.tar.gz: 2a66a02666e43b17c5007f2ae99c08f331cc46eb4645330b0f3df31fec39080ab779860bebcaa40add2beacc057d7a4ce586a7bc4453c50ddb0c4a10b677281f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 0.17.0
|
4
|
+
|
5
|
+
- Adds `sentinel_username` and `sentinel_password` options for `RedisClient#sentinel`
|
6
|
+
|
3
7
|
# 0.16.0
|
4
8
|
|
5
9
|
- Add `RedisClient#disable_reconnection`.
|
@@ -71,7 +75,7 @@
|
|
71
75
|
|
72
76
|
- Make the client resilient to `Timeout.timeout` or `Thread#kill` use (it still is very much discouraged to use either).
|
73
77
|
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).
|
78
|
+
- hiredis: handle commands returning a top-level `false` (no command does this today, but some extensions might).
|
75
79
|
- 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
80
|
|
77
81
|
# 0.8.0
|
@@ -90,7 +94,7 @@
|
|
90
94
|
|
91
95
|
- Raise a distinct `RedisClient::OutOfMemoryError`, for Redis `OOM` errors.
|
92
96
|
- Fix the instrumentation API to be called even for authentication commands.
|
93
|
-
- Fix `url:` configuration to accept a trailing slash.
|
97
|
+
- Fix `url:` configuration to accept a trailing slash.
|
94
98
|
|
95
99
|
# 0.7.1
|
96
100
|
|
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.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-
|
11
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|