redlock 0.2.1 → 0.2.2
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/Gemfile.lock +1 -1
- data/lib/redlock/client.rb +1 -1
- data/lib/redlock/version.rb +1 -1
- data/spec/client_spec.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70744bd95881adacc0fc6623a3ba75ee0840339e
|
4
|
+
data.tar.gz: 3b5b971c30395079d645eab57504ba002b7bed61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e468fb7a3a98f4cb896a8d6ac6bed4ed25574ae20b6bd9f66c478674f8a3346404dcfc063bc82e74c1669e3e5402f8b1423e381c6e520073baf652b38ef69b1
|
7
|
+
data.tar.gz: 91506cfd3c6913f84cb50ce243ad13e4b9c4593a093872f83ac9518227ca477416f022b564f4aaa9004dab6c6f083614934283f58219b0970aa0cb33140d27f7
|
data/Gemfile.lock
CHANGED
data/lib/redlock/client.rb
CHANGED
@@ -163,7 +163,7 @@ module Redlock
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def lock_instances(resource, ttl, options)
|
166
|
-
value = options
|
166
|
+
value = (options[:extend] || { value: SecureRandom.uuid })[:value]
|
167
167
|
allow_new_lock = (options[:extend_life] || options[:extend_only_if_life]) ? 'no' : 'yes'
|
168
168
|
|
169
169
|
locked, time_elapsed = timed do
|
data/lib/redlock/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -49,6 +49,14 @@ RSpec.describe Redlock::Client do
|
|
49
49
|
expect(@lock_info[:value]).to eq(my_lock_info[:value])
|
50
50
|
end
|
51
51
|
|
52
|
+
context 'when extend param is nil' do
|
53
|
+
it 'defaults to creating a new lock' do
|
54
|
+
@lock_info = lock_manager.lock(resource_key, ttl, extend: nil)
|
55
|
+
expect(@lock_info).to be_lock_info_for(resource_key)
|
56
|
+
expect(@lock_info[:value]).to be
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
52
60
|
context 'when extend_only_if_life flag is given' do
|
53
61
|
it 'does not extend a non-existent lock' do
|
54
62
|
@lock_info = lock_manager.lock(resource_key, ttl, extend: {value: 'hello world'}, extend_only_if_life: true)
|
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: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Moreira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.5.1
|
134
|
+
rubygems_version: 2.5.2.1
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Distributed lock using Redis written in Ruby.
|