redis_queued_locks 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +12 -9
- data/lib/redis_queued_locks/acquier/release.rb +1 -1
- data/lib/redis_queued_locks/version.rb +2 -2
- data/redis_queued_locks.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56120a88eb6ffa4f377c014b8619cdcd227ac0efaab1c6ec6495042c74739a63
|
4
|
+
data.tar.gz: d1e7240b5ca0c8a18842cd609b1e9280813a0a51a62d2ed9bcacdb66d707801f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3df6ebf409fa4d97ebe51632832d6c9c64eb03a4102d68e6951def7a3d351c62e86e63014b8cc1d5c6ea4c5cd6bf9bdf5595ebdb2a3334550e7a27f2f6b0bcd
|
7
|
+
data.tar.gz: 6e512298fb8be556e5370574e87529b936670bec1b13250233c6ce08d9feb4c8032b1b07e90a514ff4d4687e01391424be5b546a124119c7937492baa7ef87ee
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# RedisQueuedLocks
|
2
2
|
|
3
|
-
Distributed
|
3
|
+
Distributed locks with "lock acquisition queue" capabilities based on the Redis Database.
|
4
|
+
|
4
5
|
Each lock request is put into a request queue and processed in order of their priority (FIFO).
|
5
6
|
|
6
7
|
---
|
@@ -18,7 +19,7 @@ Each lock request is put into a request queue and processed in order of their pr
|
|
18
19
|
- [clear_locks](#clear_locks---release-all-locks-and-lock-queues)
|
19
20
|
- [Instrumentation](#instrumentation)
|
20
21
|
- [Instrumentation Events](#instrumentation-events)
|
21
|
-
- [
|
22
|
+
- [Todo](#todo)
|
22
23
|
- [Contributing](#contributing)
|
23
24
|
- [License](#license)
|
24
25
|
- [Authors](#authors)
|
@@ -65,6 +66,7 @@ rq_lock_client = RedisQueuedLocks::Client.new(redis_client) do |config|
|
|
65
66
|
end
|
66
67
|
|
67
68
|
# Step 3: start to work with locks :)
|
69
|
+
rq_lock_client.lock("some-lock") { puts "Hello, lock!" }
|
68
70
|
```
|
69
71
|
|
70
72
|
---
|
@@ -166,9 +168,11 @@ def lock(
|
|
166
168
|
- `instrumenter` - `[#notify]`
|
167
169
|
- See RedisQueuedLocks::Instrument::ActiveSupport for example.
|
168
170
|
- `raise_errors` - `[Boolean]`
|
169
|
-
- Raise errors on library-related limits such as timeout or
|
171
|
+
- Raise errors on library-related limits such as timeout or retry count limit.
|
170
172
|
- `block` - `[Block]`
|
171
173
|
- A block of code that should be executed after the successfully acquired lock.
|
174
|
+
- If block is **passed** the obtained lock will be released after the block execution or it's ttl (what will happen first);
|
175
|
+
- If block is **not passed** the obtained lock will be released after it's ttl;
|
172
176
|
|
173
177
|
Return value:
|
174
178
|
- `[Hash<Symbol,Any>]` Format: `{ ok: true/false, result: Symbol/Hash }`;
|
@@ -191,7 +195,6 @@ Return value:
|
|
191
195
|
{ ok: false, result: :unknown }
|
192
196
|
```
|
193
197
|
|
194
|
-
|
195
198
|
---
|
196
199
|
|
197
200
|
#### #lock! - exceptional lock obtaining
|
@@ -276,9 +279,9 @@ Return:
|
|
276
279
|
|
277
280
|
## Instrumentation
|
278
281
|
|
279
|
-
An instrumentation layer is incapsulated in `instrumenter` object stored in
|
282
|
+
An instrumentation layer is incapsulated in `instrumenter` object stored in [config](#configuration) (`RedisQueuedLocks::Client#config[:instrumenter]`).
|
280
283
|
|
281
|
-
Instrumenter object should provide `notify(event, payload)` method with following signarue:
|
284
|
+
Instrumenter object should provide `notify(event, payload)` method with the following signarue:
|
282
285
|
|
283
286
|
- `event` - `string`;
|
284
287
|
- `payload` - `hash<Symbol,Any>`;
|
@@ -286,7 +289,7 @@ Instrumenter object should provide `notify(event, payload)` method with followin
|
|
286
289
|
`redis_queued_locks` provides two instrumenters:
|
287
290
|
|
288
291
|
- `RedisQueuedLocks::Instrument::ActiveSupport` - `ActiveSupport::Notifications` instrumenter
|
289
|
-
that instrument events via `ActiveSupport::Notifications`
|
292
|
+
that instrument events via `ActiveSupport::Notifications` API;
|
290
293
|
- `RedisQueuedLocks::Instrument::VoidNotifier` - instrumenter that does nothing;
|
291
294
|
|
292
295
|
By default `RedisQueuedLocks::Client` is configured with the void notifier (which means "instrumentation is disabled").
|
@@ -338,11 +341,11 @@ Detalized event semantics and payload structure:
|
|
338
341
|
|
339
342
|
---
|
340
343
|
|
341
|
-
##
|
344
|
+
## Todo
|
342
345
|
|
343
346
|
- `RedisQueuedLocks::Acquier::Try.try_to_lock` - detailed successful result analization;
|
344
347
|
- `100%` test coverage;
|
345
|
-
- better code stylization and interesting refactorings
|
348
|
+
- better code stylization and interesting refactorings;
|
346
349
|
|
347
350
|
---
|
348
351
|
|
@@ -38,7 +38,7 @@ module RedisQueuedLocks::Acquier::Release
|
|
38
38
|
count: batch_size
|
39
39
|
) do |lock_queue|
|
40
40
|
pipeline.call('ZREMRANGEBYSCORE', lock_queue, '-inf', '+inf')
|
41
|
-
pipeline.call('EXPIRE', RedisQueuedLocks::Resource.lock_key_from_queue(lock_queue),
|
41
|
+
pipeline.call('EXPIRE', RedisQueuedLocks::Resource.lock_key_from_queue(lock_queue), '0')
|
42
42
|
end
|
43
43
|
|
44
44
|
# Step B: release all locks
|
data/redis_queued_locks.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['iamdaiver@gmail.com']
|
12
12
|
|
13
13
|
spec.summary = 'Queued distributed locks based on Redis.'
|
14
|
-
spec.description = 'Distributed
|
14
|
+
spec.description = 'Distributed locks with "lock acquisition queue" ' \
|
15
15
|
'capabilities based on the Redis Database.'
|
16
16
|
spec.homepage = 'https://github.com/0exp/redis_queued_locks'
|
17
17
|
spec.license = 'MIT'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_queued_locks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
@@ -38,8 +38,8 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.28'
|
41
|
-
description: Distributed
|
42
|
-
|
41
|
+
description: Distributed locks with "lock acquisition queue" capabilities based on
|
42
|
+
the Redis Database.
|
43
43
|
email:
|
44
44
|
- iamdaiver@gmail.com
|
45
45
|
executables: []
|