redis_queued_locks 0.0.33 → 0.0.35

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: 43854a2842911dcf40e95329b2631bc6c76cdaff0cd204fb57eff55c0ee461aa
4
- data.tar.gz: c361d55a71ac4c71d307fca4a7182069d055e302ec7b65274bcbc1a4ede6f768
3
+ metadata.gz: 8e16184437150045fd98daf2ab2aaa328e0e7b0bae2a3bb513db25ea7eb535d6
4
+ data.tar.gz: 1965028261e953591dc707baea43801ed0ec506a85bd4de67c0a4e17cda52820
5
5
  SHA512:
6
- metadata.gz: 6887f12891fce49f878427b501980695872e304c1429331d23b251d2f66f2db1f07a0994952f0b4ad6d9ec9b81ea769eaefe09ab1bef0c1abcadc9770ef38344
7
- data.tar.gz: aa2f6d2cfbe72dd6bf5c637f5538ce1df7c8415579505f765b3016a4c243abc52cd1db246f51abba7efa51abef123d577e26bfee992a5484208cb1416ca00f50
6
+ metadata.gz: e0cff23e13e47de8bd207597c65e0e036bbf971caad6dbd062628ca8e1975467d52834cc83787a5b4f41b3b88310eb88fe17aba93b2776687d0e5af9913d44b4
7
+ data.tar.gz: a963e804304ff4884669244f07a41061c7cc7ed56ad72f702bc41a42e7e4f8985d4f8b27d330a62afdce652123343cddae390a75d8bd8cdbab354ac54f4dd118
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.35] - 2024-03-26
4
+ ### Changed
5
+ - The random unique client instance identifier now uses 16-byte strings instead of 10-btes in order to prevent potential collisions;
6
+
7
+ ## [0.0.34] - 2024-03-26
8
+ ### Changed
9
+ - Removing the acquirer from the request queue during a lock obtaining logic now using more proper and accurate `ZREM` instead of `ZPOPMIN` for this;
10
+
3
11
  ## [0.0.33] - 2024-03-26
4
12
  ### Added
5
13
  - Logging: added current lock data info to the detailed `#try_to_lock` log to the cases when lock is still obtained. It is suitable
@@ -9,18 +17,18 @@
9
17
  ## [0.0.32] - 2024-03-26
10
18
  ### Added
11
19
  - Support for custom metadata that merged to the lock data. This data also returned from `RedisQueudLocks::Client#lock_info` method;
12
- - Custom metadata shou;d be represented as a `key => value` `Hash` data (or `NilClass` instead);
20
+ - Custom metadata should be represented as a `key => value` `Hash` (`nil` by default);
13
21
  - Custom metadata values is returned as raw data from Redis (commonly as strings);
14
22
  - Custom metadata can not contain reserved lock data keys;
15
23
  - Reduced some memory consuption;
16
24
  ### Changed
17
- - `RedisQueuedLocks::Client#lock_info` - has keys is changed from `Symbol` type to `String` type;
18
- - `RedisQueuedLocks::Client#queue_info` - hash keys is changed from `Symbol` type to `String` type;
25
+ - `RedisQueuedLocks::Client#lock_info`: hash key types of method result is changed from `Symbol` type to `String` type;
26
+ - `RedisQueuedLocks::Client#queue_info`: hash key types of method result is changed from `Symbol` type to `String` type;
19
27
 
20
28
  ## [0.0.31] - 2024-03-25
21
29
  ### Changed
22
30
  - `:metadata` renamed to `:instrument` in order to reflect it's domain area;
23
- - `:metadata` is renamed to `:meta` and reserved for the future updates;
31
+ - `:metadata` is renamed to `:meta` and reserved for future updates;
24
32
 
25
33
  ## [0.0.30] - 2024-03-23
26
34
  ### Fixed
data/README.md CHANGED
@@ -108,7 +108,7 @@ clinet = RedisQueuedLocks::Client.new(redis_client) do |config|
108
108
  config.default_lock_ttl = 5_000
109
109
 
110
110
  # (seconds) (default: 15)
111
- # - lock request timeout. after this timeout your lock request in queue will be requeued;
111
+ # - lock request timeout. after this timeout your lock request in queue will be requeued with new position (at the end of the queue);
112
112
  config.default_queue_ttl = 15
113
113
 
114
114
  # (default: 100)
@@ -161,7 +161,6 @@ clinet = RedisQueuedLocks::Client.new(redis_client) do |config|
161
161
  # - "[redis_queued_locks.try_lock.exit__no_first]" (logs "lock_key", "queue_ttl", "acq_id", "first_acq_id_in_queue", "<current_lock_data>");
162
162
  # - "[redis_queued_locks.try_lock.exit__still_obtained]" (logs "lock_key", "queue_ttl", "acq_id", "first_acq_id_in_queue", "locked_by_acq_id", "<current_lock_data>");
163
163
  # - "[redis_queued_locks.try_lock.run__free_to_acquire]" (logs "lock_key", "queue_ttl", "acq_id");
164
- # - if logger is not configured this option does not lead to any effect;
165
164
  config.log_lock_try = false
166
165
  end
167
166
  ```
@@ -330,8 +329,7 @@ See `#lock` method [documentation](#lock---obtain-a-lock).
330
329
  - `"ts"` - `integer`/`epoch` - the time lock was obtained;
331
330
  - `"init_ttl"` - `integer` - (milliseconds) initial lock key ttl;
332
331
  - `"rem_ttl"` - `integer` - (milliseconds) remaining lock key ttl;
333
- - custom metadata keys - `String` - custom metadata passed to the `lock`/`lock!`
334
- methods via `meta:` keyword argument (see [lock]((#lock---obtain-a-lock)) method documentation);
332
+ - `custom metadata`- `string`/`integer` - custom metadata passed to the `lock`/`lock!` methods via `meta:` keyword argument (see [lock]((#lock---obtain-a-lock)) method documentation);
335
333
 
336
334
  ```ruby
337
335
  # without custom metadata
@@ -640,16 +638,14 @@ Detalized event semantics and payload structure:
640
638
  - `100%` test coverage;
641
639
  - per-block-holding-the-lock sidecar `Ractor` and `in progress queue` in RedisDB that will extend
642
640
  the acquired lock for long-running blocks of code (that invoked "under" the lock
643
- whose ttl may expire before the block execution completes). It only makes sens for non-`timed` locks
644
- (for those locks where otaned with `timed: false` option);
645
- - an ability to add custom metadata to the lock and an ability to read this data;
641
+ whose ttl may expire before the block execution completes). It only makes sense for non-`timed` locks;
646
642
  - lock prioritization;
647
643
  - support for LIFO strategy;
648
- - structured logging;
644
+ - structured logging (separated docs);
649
645
  - GitHub Actions CI;
650
646
  - `RedisQueuedLocks::Acquier::Try.try_to_lock` - detailed successful result analization;
651
647
  - better code stylization and interesting refactorings;
652
- - dead queue cleanup;
648
+ - dead queue keys cleanup (empty queues);
653
649
  - statistics with UI;
654
650
  - support for `Dragonfly` DB backend;
655
651
  - support for `Garnet` DB backend;
@@ -64,7 +64,9 @@ module RedisQueuedLocks::Acquier::AcquireLock::TryToLock
64
64
  end
65
65
  end
66
66
 
67
- # Step 0: watch the lock key changes (and discard acquirement if lock is already acquired)
67
+ # Step 0:
68
+ # watch the lock key changes (and discard acquirement if lock is already
69
+ # obtained by another acquier during the current lock acquiremntt)
68
70
  rconn.multi(watch: [lock_key]) do |transact|
69
71
  # Fast-Step X0: fail-fast check
70
72
  if fail_fast && rconn.call('HGET', lock_key, 'acq_id')
@@ -216,7 +218,7 @@ module RedisQueuedLocks::Acquier::AcquireLock::TryToLock
216
218
  # NOTE: required lock is free and ready to be acquired! acquire!
217
219
 
218
220
  # Step 6.1: remove our acquier from waiting queue
219
- transact.call('ZPOPMIN', lock_key_queue, '1')
221
+ transact.call('ZREM', lock_key_queue, acquier_id)
220
222
 
221
223
  RedisQueuedLocks.debug(
222
224
  'Step №4: Забираем наш текущий процесс из очереди. [ZPOPMIN]'
@@ -22,7 +22,7 @@ module RedisQueuedLocks::Resource
22
22
  LOCK_QUEUE_PATTERN = 'rql:lock_queue:*'
23
23
 
24
24
  class << self
25
- # Returns 10-byte unique identifier. It is used for uniquely
25
+ # Returns 16-byte unique identifier. It is used for uniquely
26
26
  # identify current process between different nodes/pods of your application
27
27
  # during the lock obtaining and self-identifying in the lock queue.
28
28
  #
@@ -31,7 +31,7 @@ module RedisQueuedLocks::Resource
31
31
  # @api private
32
32
  # @since 0.1.0
33
33
  def calc_uniq_identity
34
- SecureRandom.hex(5)
34
+ SecureRandom.hex(8)
35
35
  end
36
36
 
37
37
  # @param process_id [Integer,String]
@@ -5,6 +5,6 @@ module RedisQueuedLocks
5
5
  #
6
6
  # @api public
7
7
  # @since 0.0.1
8
- # @version 0.0.33
9
- VERSION = '0.0.33'
8
+ # @version 0.0.35
9
+ VERSION = '0.0.35'
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: 0.0.33
4
+ version: 0.0.35
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-03-25 00:00:00.000000000 Z
11
+ date: 2024-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client