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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bdda4faebf87c2d1fb0026a3142497d5ae14092340bce6e35e46f51635e5c6a
4
- data.tar.gz: a9f5636898a2a3ece98b95a286bd88f417e68d119b1f1ad60bd75b5d1da94baf
3
+ metadata.gz: eb95cd103dd1856b7c75459b121bd5905d2884f520850552552bdb1c39f7502b
4
+ data.tar.gz: 165945b2aca8e081ad2704fa9eb699bd2e08e75f973fc7ae802163eed88dce8b
5
5
  SHA512:
6
- metadata.gz: 0b10ec10f00ce9282d604b1d0c8a2e845d8d95a6684a5a235d6d39b598efa6324725c4d088e8016b11d473b0195a1e29a451e79fad115f04f6b217493be297cf
7
- data.tar.gz: e1d54bb8bb8a108e0989d1c11baa44cbfc4c971029fb23819d000758b42739698342ef803a826990757c888d113fb8a49663df1f3812603965c5498361596f86
6
+ metadata.gz: 79ba3e5ab3dc1704b2af22efb3f038a43b8b9fd773492ba8e6d8f8e0b162cdd4df3671e2267ac80ff3e1f1a3d0edb3b3cc29430637f6d3efa146fd1f6d4fd100
7
+ data.tar.gz: '0929d107e6ffb002498a26b5afe0d59e41eacc7265ade1402584b1c25a52509ddbedd40eb24acfacfefa718f343ffe9f055adff4f3f7b390e61971543dea4451'
@@ -13,7 +13,7 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- ruby-version: [3.1, "3.0", "2.7", "2.6", "2.5", "ruby-head"]
16
+ ruby-version: [3.2, 3.1, "3.0", "2.7", "2.6", "2.5", "ruby-head"]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v2
@@ -169,12 +169,35 @@ module Redlock
169
169
  if connection.respond_to?(:client)
170
170
  @redis = connection
171
171
  else
172
- @redis = RedisClient.new(connection)
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|
@@ -1,3 +1,3 @@
1
1
  module Redlock
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
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', '~> 0.14.1'
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.2
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-06-15 00:00:00.000000000 Z
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.3.7
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: