redlock 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/lib/redlock/client.rb +24 -1
- data/lib/redlock/version.rb +1 -1
- data/redlock.gemspec +1 -1
- data/spec/client_spec.rb +10 -0
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb95cd103dd1856b7c75459b121bd5905d2884f520850552552bdb1c39f7502b
|
4
|
+
data.tar.gz: 165945b2aca8e081ad2704fa9eb699bd2e08e75f973fc7ae802163eed88dce8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79ba3e5ab3dc1704b2af22efb3f038a43b8b9fd773492ba8e6d8f8e0b162cdd4df3671e2267ac80ff3e1f1a3d0edb3b3cc29430637f6d3efa146fd1f6d4fd100
|
7
|
+
data.tar.gz: '0929d107e6ffb002498a26b5afe0d59e41eacc7265ade1402584b1c25a52509ddbedd40eb24acfacfefa718f343ffe9f055adff4f3f7b390e61971543dea4451'
|
data/.github/workflows/ci.yml
CHANGED
data/lib/redlock/client.rb
CHANGED
@@ -169,12 +169,35 @@ module Redlock
|
|
169
169
|
if connection.respond_to?(:client)
|
170
170
|
@redis = connection
|
171
171
|
else
|
172
|
-
@redis =
|
172
|
+
@redis = initialize_client(connection)
|
173
173
|
end
|
174
174
|
@redis.extend(ConnectionPoolLike)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
+
def initialize_client(options)
|
179
|
+
if options.key?(:sentinels)
|
180
|
+
if url = options.delete(:url)
|
181
|
+
uri = URI.parse(url)
|
182
|
+
if !options.key?(:name) && uri.host
|
183
|
+
options[:name] = uri.host
|
184
|
+
end
|
185
|
+
|
186
|
+
if !options.key?(:password) && uri.password && !uri.password.empty?
|
187
|
+
options[:password] = uri.password
|
188
|
+
end
|
189
|
+
|
190
|
+
if !options.key?(:username) && uri.user && !uri.user.empty?
|
191
|
+
options[:username] = uri.user
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
RedisClient.sentinel(**options).new_client
|
196
|
+
else
|
197
|
+
RedisClient.config(**options).new_client
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
178
201
|
def lock(resource, val, ttl, allow_new_lock)
|
179
202
|
recover_from_script_flush do
|
180
203
|
@redis.with { |conn|
|
data/lib/redlock/version.rb
CHANGED
data/redlock.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'redis-client', '
|
21
|
+
spec.add_dependency 'redis-client', '>= 0.14.1', '< 1.0.0'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'connection_pool', '~> 2.2'
|
24
24
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
data/spec/client_spec.rb
CHANGED
@@ -59,6 +59,16 @@ RSpec.describe Redlock::Client do
|
|
59
59
|
lock_manager.unlock(lock_info)
|
60
60
|
end
|
61
61
|
|
62
|
+
it 'accepts Configuration hashes' do
|
63
|
+
config = { url: "redis://#{redis1_host}:#{redis1_port}" }
|
64
|
+
_redlock = Redlock::Client.new([config])
|
65
|
+
|
66
|
+
lock_info = lock_manager.lock(resource_key, ttl)
|
67
|
+
expect(lock_info).to be_a(Hash)
|
68
|
+
expect(resource_key).to_not be_lockable(lock_manager, ttl)
|
69
|
+
lock_manager.unlock(lock_info)
|
70
|
+
end
|
71
|
+
|
62
72
|
it 'does not load scripts' do
|
63
73
|
redis_client.call('SCRIPT', 'FLUSH')
|
64
74
|
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redlock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Moreira
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.14.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.14.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: connection_pool
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,7 +150,7 @@ homepage: https://github.com/leandromoreira/redlock-rb
|
|
144
150
|
licenses:
|
145
151
|
- BSD-2-Clause
|
146
152
|
metadata: {}
|
147
|
-
post_install_message:
|
153
|
+
post_install_message:
|
148
154
|
rdoc_options: []
|
149
155
|
require_paths:
|
150
156
|
- lib
|
@@ -159,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
165
|
- !ruby/object:Gem::Version
|
160
166
|
version: '0'
|
161
167
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
163
|
-
signing_key:
|
168
|
+
rubygems_version: 3.4.10
|
169
|
+
signing_key:
|
164
170
|
specification_version: 4
|
165
171
|
summary: Distributed lock using Redis written in Ruby.
|
166
172
|
test_files:
|