redis_queued_locks 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83f1a77fc07b776195720c2f06a7117baa22ea7f68be06120d3fe7befe26db84
4
- data.tar.gz: 4a06cb4f59afb485331513ab01172c2836f07702bd79fdc85c95efaa459a2597
3
+ metadata.gz: 6b175564df436902d56e07a376f0257118eced8d7c81dbb81837e63cdef74938
4
+ data.tar.gz: f88d3e83045cb4dd4dcd10b12744399ce45d3b99a84f6ca492d801a678db55f0
5
5
  SHA512:
6
- metadata.gz: ebae6ceee85253f767b0de53b70a69f00590e91bbcdb6c86860c35a00d736f59593f924eaccb13b593def1f9b504f338f786a2eeb59f9dcd4a596c9d70f2f348
7
- data.tar.gz: 5e6e97c4645df750d618c778caccd80fa3eab1491e141b238e5e4c1ed15f59c72871c00f10d38269f33ada195b96ed5b407a62cc52d2543a169b150d2150c770
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 and #keys operations (uses SCAN);
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: false,
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: caclically try to obtain the lock
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
- # - the time period (in millsiecnds) after whcih the lock request is
406
- # considered as dead;
407
- # - `config[:dead_request_ttl]` is used by default;
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
- # The batch of scanned keys for Redis'es SCAN command.
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[:key_extraction_batch_size],
421
+ scan_size: config[:lock_release_batch_size],
421
422
  logger: config[:logger],
422
423
  instrumenter: config[:instrumenter],
423
424
  instrument: nil
@@ -5,6 +5,6 @@ module RedisQueuedLocks
5
5
  #
6
6
  # @api public
7
7
  # @since 0.0.1
8
- # @version 1.0.0
9
- VERSION = '1.0.0'
8
+ # @version 1.1.0
9
+ VERSION = '1.1.0'
10
10
  end
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.0.0
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-01 00:00:00.000000000 Z
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.3.7
111
+ rubygems_version: 3.5.1
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Queued distributed locks based on Redis.