redis_queued_locks 0.0.9 → 0.0.10
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +7 -5
- data/lib/redis_queued_locks/acquier.rb +11 -0
- data/lib/redis_queued_locks/client.rb +10 -0
- data/lib/redis_queued_locks/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28714dd149659f7c58634868219b3e020df6304253db120fda241304a82ce781
|
4
|
+
data.tar.gz: 52e9193aa4945598f7da31d202cfc445f2b5b63009f5f09e260a732b02e3ac64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0f02df991559f21667288ebf690695909d65766cb2c9dd809d18d62a34e722d35d898e227ef38cf12d5acf96d271b7c0a078b1aa8ce47b93645fdd27b36d043
|
7
|
+
data.tar.gz: 5f60948e47cebdc9ff2de6a594aa68155c39ee262fd0662afbe293b672ce811c74a5182f8793be7d3860a8361560213108f25fd00d8a1891cd72a353d3103b25
|
data/CHANGELOG.md
CHANGED
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
|
-
|
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
|
```
|
@@ -198,7 +199,7 @@ Return value:
|
|
198
199
|
ok: true,
|
199
200
|
result: {
|
200
201
|
lock_key: String, # acquierd lock key ("rql:lock:your_lock_name")
|
201
|
-
acq_id: String, # acquier identifier ("
|
202
|
+
acq_id: String, # acquier identifier ("process_id/thread_id/fiber_id/ractor_id/identity")
|
202
203
|
ts: Integer, # time (epoch) when lock was obtained (integer)
|
203
204
|
ttl: Integer # lock's time to live in milliseconds (integer)
|
204
205
|
}
|
@@ -243,7 +244,7 @@ See `#lock` method [documentation](#lock---obtain-a-lock).
|
|
243
244
|
- returns `nil` if lock does not exist;
|
244
245
|
- lock data (`Hash<Symbol,String|Integer>`):
|
245
246
|
- `lock_key` - `string` - lock key in redis;
|
246
|
-
- `acq_id` - `string` - acquier identifier (process_id/thread_id/fiber_id/ractor_id/identity
|
247
|
+
- `acq_id` - `string` - acquier identifier (process_id/thread_id/fiber_id/ractor_id/identity);
|
247
248
|
- `ts` - `integer`/`epoch` - the time lock was obtained;
|
248
249
|
- `init_ttl` - `integer` - (milliseconds) initial lock key ttl;
|
249
250
|
- `rem_ttl` - `integer` - (milliseconds) remaining lock key ttl;
|
@@ -254,7 +255,7 @@ rql.lock_info("your_lock_name")
|
|
254
255
|
# =>
|
255
256
|
{
|
256
257
|
lock_key: "rql:lock:your_lock_name",
|
257
|
-
acq_id: "rql:acq:123/456",
|
258
|
+
acq_id: "rql:acq:123/456/567/678/374dd74324",
|
258
259
|
ts: 123456789,
|
259
260
|
ini_ttl: 123456789,
|
260
261
|
rem_ttl: 123456789
|
@@ -429,7 +430,7 @@ Detalized event semantics and payload structure:
|
|
429
430
|
- payload:
|
430
431
|
- `rel_time` - `float`/`milliseconds` - time spent on "realese all locks" operation;
|
431
432
|
- `at` - `integer`/`epoch` - the time when the operation has ended;
|
432
|
-
- `rel_keys` - `integer` - released redis keys count (`released
|
433
|
+
- `rel_keys` - `integer` - released redis keys count (`released queue keys` + `released lock keys`);
|
433
434
|
|
434
435
|
---
|
435
436
|
|
@@ -438,6 +439,7 @@ Detalized event semantics and payload structure:
|
|
438
439
|
- **Major**
|
439
440
|
- Semantic Error objects for unexpected Redis errors;
|
440
441
|
- `100%` test coverage;
|
442
|
+
- 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
443
|
- **Minor**
|
442
444
|
- `RedisQueuedLocks::Acquier::Try.try_to_lock` - detailed successful result analization;
|
443
445
|
- 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
|
#
|