redis_queued_locks 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +26 -2
- data/lib/redis_queued_locks/acquier/acquire_lock.rb +1 -1
- data/lib/redis_queued_locks/client.rb +6 -5
- 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: 6b175564df436902d56e07a376f0257118eced8d7c81dbb81837e63cdef74938
|
4
|
+
data.tar.gz: f88d3e83045cb4dd4dcd10b12744399ce45d3b99a84f6ca492d801a678db55f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae486564a408bc9039d6b09f3fe08ba37e733bae902ec2c3f55eae84b22a05e6c6f31bc9ceafc5ee78a10ae34dfdc0b3e7dcbfb09a41f74795ed29dce823a6bc
|
7
|
+
data.tar.gz: ba40ab572fb1863b0bcddee6536385d19e3b3c7c9df07b2e2d71d74ad740eccb05a18847222be70bf6796596ce2b93266dbf462dccab294c6200a4441ca1f1a7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.1.0] - 2024-04-01
|
4
|
+
### Added
|
5
|
+
- Documentation updates:
|
6
|
+
- more `#lock` examples;
|
7
|
+
- added missing docs for `config.dead_request_ttl`;
|
8
|
+
- some minor updates;
|
9
|
+
### Changed
|
10
|
+
- `#clear_dead_requests`: `:scan_size` is equal to `config[:lock_release_batch_size]` now (instead of to `config[:key_extraction_batch_size]`);
|
11
|
+
cuz `#clear_dead_requests` works with lock releasing;
|
12
|
+
|
3
13
|
## [1.0.0] - 2024-04-01
|
4
14
|
- First Major Release;
|
5
15
|
|
data/README.md
CHANGED
@@ -155,10 +155,16 @@ clinet = RedisQueuedLocks::Client.new(redis_client) do |config|
|
|
155
155
|
config.lock_release_batch_size = 100
|
156
156
|
|
157
157
|
# (default: 500)
|
158
|
-
# - how many items should be extracted from redis during the #locks, #queues
|
158
|
+
# - how many items should be extracted from redis during the #locks, #queues, #keys
|
159
|
+
# #locks_info, and #queues_info operations (uses SCAN);
|
159
160
|
# - affects the performance of your Redis and Ruby Application (configure thoughtfully;)
|
160
161
|
config.key_extraction_batch_size = 500
|
161
162
|
|
163
|
+
# (default: 1 day)
|
164
|
+
# - the default period of time (in milliseconds) after which a lock request is considered dead;
|
165
|
+
# - used for `#clear_dead_requests` as default vaule of `:dead_ttl` option;
|
166
|
+
config.dead_request_ttl = (1 * 24 * 60 * 60 * 1000) # one day in milliseconds
|
167
|
+
|
162
168
|
# (default: RedisQueuedLocks::Instrument::VoidNotifier)
|
163
169
|
# - instrumentation layer;
|
164
170
|
# - you can provde your own instrumenter with `#notify(event, payload = {})`
|
@@ -245,7 +251,7 @@ def lock(
|
|
245
251
|
ttl: config[:default_lock_ttl],
|
246
252
|
queue_ttl: config[:default_queue_ttl],
|
247
253
|
timeout: config[:try_to_lock_timeout],
|
248
|
-
timed:
|
254
|
+
timed: config[:is_timed_by_default],
|
249
255
|
retry_count: config[:retry_count],
|
250
256
|
retry_delay: config[:retry_delay],
|
251
257
|
retry_jitter: config[:retry_jitter],
|
@@ -429,6 +435,24 @@ rql.lock("my_lock", ttl: 6_500) # blocks execution until the lock is obtained
|
|
429
435
|
puts "Let's go" # will be called immediately after the lock is obtained
|
430
436
|
```
|
431
437
|
|
438
|
+
- add custom metadata to the lock (via `:meta` option):
|
439
|
+
|
440
|
+
```ruby
|
441
|
+
rql.lock("my_lock", ttl: 123456, meta: { "some" => "data", key: 123.456 })
|
442
|
+
|
443
|
+
rql.lock_info("my_lock")
|
444
|
+
# =>
|
445
|
+
{
|
446
|
+
"lock_key" => "rql:lock:my_lock",
|
447
|
+
"acq_id" => "rql:acq:123/456/567/678/374dd74324",
|
448
|
+
"ts" => 123456789,
|
449
|
+
"ini_ttl" => 123456,
|
450
|
+
"rem_ttl" => 123440,
|
451
|
+
"some" => "data",
|
452
|
+
"key" => "123.456" # NOTE: returned as a raw string directly from Redis
|
453
|
+
}
|
454
|
+
```
|
455
|
+
|
432
456
|
---
|
433
457
|
|
434
458
|
#### #lock! - exceptional lock obtaining
|
@@ -186,7 +186,7 @@ module RedisQueuedLocks::Acquier::AcquireLock
|
|
186
186
|
with_acq_timeout(timeout, lock_key, raise_errors, on_timeout: acq_dequeue) do
|
187
187
|
acq_start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
|
188
188
|
|
189
|
-
# Step 2.1:
|
189
|
+
# Step 2.1: cyclically try to obtain the lock
|
190
190
|
while acq_process[:should_try]
|
191
191
|
run_non_critical do
|
192
192
|
logger.debug do
|
@@ -402,11 +402,12 @@ class RedisQueuedLocks::Client
|
|
402
402
|
end
|
403
403
|
|
404
404
|
# @option dead_ttl [Integer]
|
405
|
-
#
|
406
|
-
#
|
407
|
-
#
|
405
|
+
# - the time period (in millsiecnds) after whcih the lock request is
|
406
|
+
# considered as dead;
|
407
|
+
# - `config[:dead_request_ttl]` is used by default;
|
408
408
|
# @option scan_size [Integer]
|
409
|
-
#
|
409
|
+
# - the batch of scanned keys for Redis'es SCAN command;
|
410
|
+
# - `config[:lock_release_batch_size]` is used by default;
|
410
411
|
# @option logger [::Logger,#debug]
|
411
412
|
# @option instrumenter [#notify]
|
412
413
|
# @option instrument [NilClass,Any]
|
@@ -417,7 +418,7 @@ class RedisQueuedLocks::Client
|
|
417
418
|
# @since 0.1.0
|
418
419
|
def clear_dead_requests(
|
419
420
|
dead_ttl: config[:dead_request_ttl],
|
420
|
-
scan_size: config[:
|
421
|
+
scan_size: config[:lock_release_batch_size],
|
421
422
|
logger: config[:logger],
|
422
423
|
instrumenter: config[:instrumenter],
|
423
424
|
instrument: nil
|
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.
|
4
|
+
version: 1.1.0
|
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-04-
|
11
|
+
date: 2024-04-02 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.
|