redis_queued_locks 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +24 -13
- data/lib/redis_queued_locks/acquier/acquire_lock.rb +2 -2
- data/lib/redis_queued_locks/version.rb +2 -2
- 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: 5cac51b8b6c2a4986c188d7b419e11a282c4a18d6a32689000a2c9127f77eec3
|
4
|
+
data.tar.gz: d159e30574e503a714081dfda22d9085553818573ad968f745e302efe93edfde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ee000a0470297832a593a8719a192feb5fdf583003d49f8dfb3335dad4c63aff45730cc8d4481a02eb41f629e60d929349fcc1842025117bd5b35304a09c8cd
|
7
|
+
data.tar.gz: c7e52ef09012e29a2ac1495fedc287c7a51c5fee8ceac466f78d5de548e8231b7a5c8fc29626db28ca82629ac0294b4ded991cbf5902f97a76619279bed4e353
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.3.1] - 2024-05-10
|
4
|
+
### Fixed
|
5
|
+
- `:meta` attribute type validation of `#lock`/`#lock!` was incorrect;
|
6
|
+
### Added
|
7
|
+
- documentation updates and clarifications;
|
8
|
+
|
3
9
|
## [1.3.0] - 2024-05-08
|
4
10
|
### Added
|
5
11
|
- **Major Feature**: support for **Reentrant Locks**;
|
data/README.md
CHANGED
@@ -151,7 +151,9 @@ clinet = RedisQueuedLocks::Client.new(redis_client) do |config|
|
|
151
151
|
config.is_timed_by_default = false
|
152
152
|
|
153
153
|
# (symbol) (default: :wait_for_lock)
|
154
|
-
# -
|
154
|
+
# - Global default conflict strategy mode;
|
155
|
+
# - Can be customized in methods `#lock` and `#lock` via `:conflict_strategy` attribute (see method signatures of #lock and #lock! methods);
|
156
|
+
# - Conflict strategy is a logical behavior for cases when the process that obtained the lock want to acquire this lock again;
|
155
157
|
# - Realizes "reentrant locks" abstraction (same process conflict / same process deadlock);
|
156
158
|
# - By default uses `:wait_for_lock` strategy (classic way);
|
157
159
|
# - Strategies:
|
@@ -159,7 +161,6 @@ clinet = RedisQueuedLocks::Client.new(redis_client) do |config|
|
|
159
161
|
# - `:extendable_work_through` - continue working under the lock <with> lock's TTL extension;
|
160
162
|
# - `:wait_for_lock` - (default) - work in classic way (with timeouts, retry delays, retry limits, etc - in classic way :));
|
161
163
|
# - `:dead_locking` - fail with deadlock exception;
|
162
|
-
# - Can be customized in methods via `:conflict_strategy` attribute (see method signatures of #lock and #lock! methods);
|
163
164
|
# - See "Dead locks and Reentrant Locks" documentation section in REDME.md for details;
|
164
165
|
config.default_conflict_strategy = :wait_for_lock
|
165
166
|
|
@@ -262,10 +263,14 @@ end
|
|
262
263
|
|
263
264
|
<sup>\[[back to top](#usage)\]</sup>
|
264
265
|
|
265
|
-
-
|
266
|
-
- If block is
|
267
|
-
-
|
268
|
-
-
|
266
|
+
- `#lock` - obtain a lock;
|
267
|
+
- If block is passed:
|
268
|
+
- the obtained lock will be released after the block execution or the lock's ttl (what will happen first);
|
269
|
+
- if you want to timeout (fail with timeout) the block execution with lock's TTL use `timed: true` option;
|
270
|
+
- the block's result will be returned;
|
271
|
+
- If block is not passed:
|
272
|
+
- the obtained lock will be released after lock's ttl;
|
273
|
+
- the lock information will be returned (hash with technical info that contains: lock key, acquier identifier, acquirement timestamp, lock's ttl, type of obtaining process, etc);
|
269
274
|
|
270
275
|
```ruby
|
271
276
|
def lock(
|
@@ -543,10 +548,12 @@ rql.lock("my_lock", queue_ttl: 5, timeout: 10_000, retry_count: nil)
|
|
543
548
|
|
544
549
|
<sup>\[[back to top](#usage)\]</sup>
|
545
550
|
|
551
|
+
- `#lock!` - exceptional lock obtaining;
|
546
552
|
- fails when (and with):
|
547
553
|
- (`RedisQueuedLocks::LockAlreadyObtainedError`) when `fail_fast` is `true` and lock is already obtained;
|
548
554
|
- (`RedisQueuedLocks::LockAcquiermentTimeoutError`) `timeout` limit reached before lock is obtained;
|
549
555
|
- (`RedisQueuedLocks::LockAcquiermentRetryLimitError`) `retry_count` limit reached before lock is obtained;
|
556
|
+
- (`RedisQueuedLocks::ConflictLockObtainError`) when `conflict_strategy: :dead_locking` is used and the "same-process-dead-lock" is happened (see [Dead locks and Reentrant locks](#dead-locks-and-reentrant-locks) for details);
|
550
557
|
|
551
558
|
```ruby
|
552
559
|
def lock!(
|
@@ -648,7 +655,7 @@ rql.lock_info("your_lock_name")
|
|
648
655
|
# ==> keys for extendable reentarnt locks with `:extendable_work_through` strategy:
|
649
656
|
"spc_ext_ttl" => 5_000, # sum of TTL of the each <extendable> reentrant lock (3_000 + 2_000)
|
650
657
|
"l_spc_ext_ini_ttl" => 2_000, # TTL of the last <extendable> reentrant lock
|
651
|
-
"l_spc_ext_ts" => 123456792.12345 # timestamp of the last <extendable> reentrant lock obtaining
|
658
|
+
"l_spc_ext_ts" => 123456792.12345, # timestamp of the last <extendable> reentrant lock obtaining
|
652
659
|
# ==> keys for non-extendable locks with `:work_through` strategy:
|
653
660
|
"l_spc_ts" => 123456.789 # timestamp of the last <non-extendable> reentrant lock obtaining
|
654
661
|
}
|
@@ -1073,13 +1080,17 @@ rql.clear_dead_requests(dead_ttl: 60 * 60 * 1000) # 1 hour in milliseconds
|
|
1073
1080
|
|
1074
1081
|
<sup>\[[back to top](#table-of-contents)\]</sup>
|
1075
1082
|
|
1076
|
-
- **documentation is in progress
|
1077
|
-
- (little details for a context of current implementation and feautres):
|
1078
|
-
- at this moment we support only **reentrant locks**: they works via customizable conflict strategy behavior
|
1079
|
-
|
1083
|
+
- **this documentation section is in progress**;
|
1084
|
+
- (little details for a context of the current implementation and feautres):
|
1085
|
+
- at this moment we support only **reentrant locks**: they works via customizable conflict strategy behavior
|
1086
|
+
(`:wait_for_lock` (default), `:work_through`, `:extendable_work_through`, `:dead_locking`);
|
1087
|
+
- by default behavior (`:wait_for_lock`) your lock obtaining process will work in a classic way (limits, retries, etc);
|
1088
|
+
- `:work_through`, `:extendable_work_through` works with limits too (timeouts, delays, etc), but the decision of
|
1089
|
+
"is your lock are obtained or not" is made as you work with **reentrant locks** (your process continues to use the lock without/without
|
1090
|
+
lock's TTL accordingly);
|
1080
1091
|
- for current implementation details check:
|
1081
|
-
- (
|
1082
|
-
- (#lock)
|
1092
|
+
- [Configuration](#configuration) documentation: see `config.default_conflict_strategy` config docs;
|
1093
|
+
- [#lock](#lock---obtain-a-lock) method documentation: see `conflict_strategy` attribute docs and the method result data;
|
1083
1094
|
|
1084
1095
|
---
|
1085
1096
|
|
@@ -94,7 +94,7 @@ module RedisQueuedLocks::Acquier::AcquireLock
|
|
94
94
|
#
|
95
95
|
# @api private
|
96
96
|
# @since 1.0.0
|
97
|
-
# @version 1.3.
|
97
|
+
# @version 1.3.1
|
98
98
|
def acquire_lock(
|
99
99
|
redis,
|
100
100
|
lock_name,
|
@@ -132,7 +132,7 @@ module RedisQueuedLocks::Acquier::AcquireLock
|
|
132
132
|
end
|
133
133
|
|
134
134
|
# Step 0.2: prevent :meta incompatabiltiies (structure)
|
135
|
-
if meta
|
135
|
+
if meta.is_a?(::Hash) && (meta.keys.any? do |key|
|
136
136
|
key == 'acq_id' ||
|
137
137
|
key == 'ts' ||
|
138
138
|
key == 'ini_ttl' ||
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_queued_locks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
111
|
+
rubygems_version: 3.5.1
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Queued distributed locks based on Redis.
|