redis_queued_locks 0.0.9 → 0.0.11

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: 463b0613174c7a3806aef19ce962bbe5ed91d342796bec84ea47b2aa79cf61fb
4
- data.tar.gz: 4d483db40896d77049e3e6d324a206606225c9c8e8b592072b1f501563fb7ec8
3
+ metadata.gz: 98c4154b27f6f87e29870ca00e4372d70243dcb528311030a7715de138cb2039
4
+ data.tar.gz: 0b7fe57e396bb7f13932417e963a5a53f530255db525dcf3d261d41e08a8396a
5
5
  SHA512:
6
- metadata.gz: f829f8afc264f8a44d0edd1469c5ada76c7257f15ef6945c3f154fe2908b29d5ace4ce0c11365a30af1cdbb6d3b4aeec30227b84500da65b720f22247ed96053
7
- data.tar.gz: 1eee0e4c2a665b57ee6d2c2c2d6488c065bbcdd586cfe06f2890a6b412a3a009675dd26e39383f2fad54434288d4c3c7660fba2faaa3013da98ab27c484b08b0
6
+ metadata.gz: 7a441b4848cb2471f694dc8f7f17e6471bf5f7957a5e37eadcdd0da23a4b0d50e3183575530fc764d5e262eea0898699b584393674a994411c7bd6ec18e02a81
7
+ data.tar.gz: 362ffaf848de14c6e42f79822a2e41a39f02b88aad8d5abb1ed79df235ffbb2dc7c42063bb6bee2aab5b9b7fc2d836498446734ee64b8d31001445ca3430e6f9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.11] - 2024-02-27
4
+ ### Changed
5
+ - Minor documentation updates;
6
+
7
+ ## [0.0.10] - 2024-02-27
8
+ ### Changed
9
+ - Minor documentation updates;
10
+
3
11
  ## [0.0.9] - 2024-02-27
4
12
  ### Changed
5
13
  - The lock acquier identifier (`acq_id`) now includes the fiber id, the ractor id and an unique per-process
data/README.md CHANGED
@@ -60,7 +60,7 @@ require 'redis_queued_locks'
60
60
  require 'redis_queued_locks'
61
61
 
62
62
  # Step 1: initialize RedisClient instance
63
- redis_clinet = RedisClient.config.new_pool # NOTE: provide your own RedisClient instance
63
+ redis_client = RedisClient.config.new_pool # NOTE: provide your own RedisClient instance
64
64
 
65
65
  # Step 2: initialize RedisQueuedLock::Client instance
66
66
  rq_lock_client = RedisQueuedLocks::Client.new(redis_client) do |config|
@@ -125,6 +125,7 @@ clinet = RedisQueuedLocks::Client.new(redis_client) do |config|
125
125
  # - prevents potential lock-acquirement collisions bettween different process/pods
126
126
  # that have identical process_id/thread_id/fiber_id/ractor_id (identivcal acquier ids);
127
127
  # - it is calculated once per `RedisQueudLocks::Client` instance;
128
+ # - expects the proc object;
128
129
  config.uniq_identifier = -> { RedisQueuedLocks::Resource.calc_uniq_identity }
129
130
  end
130
131
  ```
@@ -146,6 +147,10 @@ end
146
147
 
147
148
  #### #lock - obtain a lock
148
149
 
150
+ - If block is passed the obtained lock will be released after the block execution or the lock's ttl (what will happen first);
151
+ - If block is not passed the obtained lock will be released after lock's ttl;
152
+
153
+
149
154
  ```ruby
150
155
  def lock(
151
156
  lock_name,
@@ -198,7 +203,7 @@ Return value:
198
203
  ok: true,
199
204
  result: {
200
205
  lock_key: String, # acquierd lock key ("rql:lock:your_lock_name")
201
- acq_id: String, # acquier identifier ("your_process_id/your_thread_id")
206
+ acq_id: String, # acquier identifier ("process_id/thread_id/fiber_id/ractor_id/identity")
202
207
  ts: Integer, # time (epoch) when lock was obtained (integer)
203
208
  ttl: Integer # lock's time to live in milliseconds (integer)
204
209
  }
@@ -243,7 +248,7 @@ See `#lock` method [documentation](#lock---obtain-a-lock).
243
248
  - returns `nil` if lock does not exist;
244
249
  - lock data (`Hash<Symbol,String|Integer>`):
245
250
  - `lock_key` - `string` - lock key in redis;
246
- - `acq_id` - `string` - acquier identifier (process_id/thread_id/fiber_id/ractor_id/identity by default);
251
+ - `acq_id` - `string` - acquier identifier (process_id/thread_id/fiber_id/ractor_id/identity);
247
252
  - `ts` - `integer`/`epoch` - the time lock was obtained;
248
253
  - `init_ttl` - `integer` - (milliseconds) initial lock key ttl;
249
254
  - `rem_ttl` - `integer` - (milliseconds) remaining lock key ttl;
@@ -254,7 +259,7 @@ rql.lock_info("your_lock_name")
254
259
  # =>
255
260
  {
256
261
  lock_key: "rql:lock:your_lock_name",
257
- acq_id: "rql:acq:123/456",
262
+ acq_id: "rql:acq:123/456/567/678/374dd74324",
258
263
  ts: 123456789,
259
264
  ini_ttl: 123456789,
260
265
  rem_ttl: 123456789
@@ -429,7 +434,7 @@ Detalized event semantics and payload structure:
429
434
  - payload:
430
435
  - `rel_time` - `float`/`milliseconds` - time spent on "realese all locks" operation;
431
436
  - `at` - `integer`/`epoch` - the time when the operation has ended;
432
- - `rel_keys` - `integer` - released redis keys count (`released queu keys` + `released lock keys`);
437
+ - `rel_keys` - `integer` - released redis keys count (`released queue keys` + `released lock keys`);
433
438
 
434
439
  ---
435
440
 
@@ -438,6 +443,7 @@ Detalized event semantics and payload structure:
438
443
  - **Major**
439
444
  - Semantic Error objects for unexpected Redis errors;
440
445
  - `100%` test coverage;
446
+ - sidecar `Ractor` object and `in progress queue` in RedisDB that will extend an acquired lock for long-running blocks of code (that invoked "under" the lock);
441
447
  - **Minor**
442
448
  - `RedisQueuedLocks::Acquier::Try.try_to_lock` - detailed successful result analization;
443
449
  - better code stylization and interesting refactorings;
@@ -403,6 +403,17 @@ module RedisQueuedLocks::Acquier
403
403
  end
404
404
  end
405
405
 
406
+ # @param redis_client [RedisClient]
407
+ # @param lock_name [String]
408
+ # @param milliseconds [Integer]
409
+ # @return [?]
410
+ #
411
+ # @api private
412
+ # @since 0.1.0
413
+ def extend_lock_ttl(redis_client, lock_name, milliseconds)
414
+
415
+ end
416
+
406
417
  private
407
418
 
408
419
  # @param timeout [NilClass,Integer]
@@ -196,6 +196,16 @@ class RedisQueuedLocks::Client
196
196
  RedisQueuedLocks::Acquier.queue_info(redis_client, lock_name)
197
197
  end
198
198
 
199
+ # @param lock_name [String]
200
+ # @param milliseconds [Integer] How many milliseconds should be added.
201
+ # @return [?]
202
+ #
203
+ # @api public
204
+ # @since 0.1.0
205
+ def extend_lock_ttl(lock_name, milliseconds)
206
+ RedisQueuedLocks::Acquier.extend_lock_ttl(redis_client, lock_name)
207
+ end
208
+
199
209
  # @option batch_size [Integer]
200
210
  # @return [Hash<Symbol,Any>] Format: { ok: true/false, result: Symbol/Hash }.
201
211
  #
@@ -5,6 +5,6 @@ module RedisQueuedLocks
5
5
  #
6
6
  # @api public
7
7
  # @since 0.0.1
8
- # @version 0.0.9
9
- VERSION = '0.0.9'
8
+ # @version 0.0.11
9
+ VERSION = '0.0.11'
10
10
  end
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.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov