redlock 2.0.4 → 2.0.5
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/lib/redlock/client.rb +5 -10
- data/lib/redlock/version.rb +1 -1
- data/spec/client_spec.rb +1 -5
- 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: 7672717848770741429fd13a59ea4b6a6f734ffd8b519a9c3e27c5562f553cec
|
4
|
+
data.tar.gz: 627314f12eaf57b1e44bde9cfe2388716705c93b27f95479aa5c70553b3c754b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31b8beb93afa3cd62e741637aa221b71522810a8df54d33ea54874eed7d8fac894da1622f97528704027b870dd7945bdb53dd7424fbfb47c47430f6f659d2a90
|
7
|
+
data.tar.gz: 3602f85cafd155cdaef70499231a0885f1df13f58abc1859c526d11f43ea303a2ee746928166002b5495e53b5ce8fa84700d76c583463bed3adef25da263c5d8
|
data/lib/redlock/client.rb
CHANGED
@@ -157,24 +157,19 @@ module Redlock
|
|
157
157
|
private
|
158
158
|
|
159
159
|
class RedisInstance
|
160
|
-
module ConnectionPoolLike
|
161
|
-
def with
|
162
|
-
yield self
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
160
|
def initialize(connection)
|
167
161
|
@monitor = Monitor.new
|
168
162
|
|
169
|
-
if connection.respond_to?(:
|
163
|
+
if connection.respond_to?(:call)
|
170
164
|
@redis = connection
|
171
165
|
else
|
172
166
|
if connection.respond_to?(:client)
|
173
167
|
@redis = connection
|
174
|
-
|
168
|
+
elsif connection.respond_to?(:key?)
|
175
169
|
@redis = initialize_client(connection)
|
170
|
+
else
|
171
|
+
@redis = connection
|
176
172
|
end
|
177
|
-
@redis.extend(ConnectionPoolLike)
|
178
173
|
end
|
179
174
|
end
|
180
175
|
|
@@ -202,7 +197,7 @@ module Redlock
|
|
202
197
|
end
|
203
198
|
|
204
199
|
def synchronize
|
205
|
-
@monitor.synchronize { @redis.
|
200
|
+
@monitor.synchronize { @redis.then { |connection| yield(connection) } }
|
206
201
|
end
|
207
202
|
|
208
203
|
def lock(resource, val, ttl, allow_new_lock)
|
data/lib/redlock/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -30,11 +30,7 @@ RSpec.describe Redlock::Client do
|
|
30
30
|
let(:redis3_host) { ENV["REDIS3_HOST"] || "127.0.0.1" }
|
31
31
|
let(:redis3_port) { ENV["REDIS3_PORT"] || "6379" }
|
32
32
|
let(:unreachable_redis) {
|
33
|
-
|
34
|
-
def redis.with
|
35
|
-
yield self
|
36
|
-
end
|
37
|
-
redis
|
33
|
+
RedisClient.new(url: 'redis://localhost:46864')
|
38
34
|
}
|
39
35
|
|
40
36
|
describe 'initialize' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Moreira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|