redis_queued_locks 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c77f863ddb9f33c75a636ea12281ce1f4df1215d50f43b113b5be5f79b679526
4
- data.tar.gz: 9585690846e55b141e089d26ac160f6481297cfa6f43d21df1403411903221be
3
+ metadata.gz: 281c476c0b1318a3f061e0d22031de92983f4ebd2277bc7e024b2baf998ae559
4
+ data.tar.gz: 5547ace054290da08fb1eb26e965e2d0ff68dfc9b5c3df0adb8a77069543b8ef
5
5
  SHA512:
6
- metadata.gz: 9e132a1464d92aa59539d5489d5b7d777399de6c38f313cbad063b819e0e32503591532eb010f5c6b87da41096172e9dde8f5fa2fc84623ca2256b84cd3fa98d
7
- data.tar.gz: ea8dc9808a5c16697e5606ce8394c987ceb8df4f561fbf06250bd7669188665f56825a582e9c82240a52b6376767eedda9afeed588f960498fb32070466c512c
6
+ metadata.gz: a971c732be6ef918ae6e9fc70e4456a076b36a50622cda4e0f2b4d5d3f0cb9479e768852e391b02a6420d3de682ccca7de374cf1410b25be37a5d8cf43a4865c
7
+ data.tar.gz: ef66b70b7ef28be2b9b2422a94dc89e2fff350ad5d8ce58806f28c7742fa4a3caa5032f64d4817abd52dc4bc2ae77327dcfee79b28f462241c63fb2ddaf992eb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.0.20] - 2024-03-14
4
+ ### Added
5
+ - An ability to provide custom metadata to `lock` and `lock!` methods that will be passed
6
+ to the instrumentation level inside the `payload` parameter with `:meta` key;
7
+
3
8
  ## [0.0.19] - 2024-03-12
4
9
  ### Added
5
10
  - An ability to set the invocation time period to the block of code invoked under
data/README.md CHANGED
@@ -36,7 +36,9 @@ Each lock request is put into the request queue and processed in order of their
36
36
 
37
37
  ### Algorithm
38
38
 
39
- - soon
39
+ > Each lock request is put into the request queue and processed in order of their priority (FIFO). Each lock request lives some period of time (RTTL) which guarantees that the request queue will never be stacked.
40
+
41
+ **Soon**: detailed explanation.
40
42
 
41
43
  ---
42
44
 
@@ -174,6 +176,7 @@ def lock(
174
176
  raise_errors: false,
175
177
  fail_fast: false,
176
178
  identity: uniq_identity, # (attr_accessor) calculated during client instantiation via config[:uniq_identifier] proc;
179
+ metadata: nil,
177
180
  &block
178
181
  )
179
182
  ```
@@ -209,6 +212,8 @@ def lock(
209
212
  pods or/and nodes of your application;
210
213
  - It is calculated once during `RedisQueuedLock::Client` instantiation and stored in `@uniq_identity`
211
214
  ivar (accessed via `uniq_dentity` accessor method);
215
+ - `metadata` - `[NilClass,Any]`
216
+ - A custom metadata wich will be passed to the instrumenter's payload with :meta key;
212
217
  - `block` - `[Block]`
213
218
  - A block of code that should be executed after the successfully acquired lock.
214
219
  - If block is **passed** the obtained lock will be released after the block execution or it's ttl (what will happen first);
@@ -262,6 +267,7 @@ def lock!(
262
267
  retry_jitter: config[:retry_jitter],
263
268
  identity: uniq_identity,
264
269
  fail_fast: false,
270
+ metadata: nil,
265
271
  &block
266
272
  )
267
273
  ```
@@ -536,6 +542,7 @@ Detalized event semantics and payload structure:
536
542
  - `:lock_key` - `string` - lock name;
537
543
  - `:ts` - `integer`/`epoch` - the time when the lock was obtaiend;
538
544
  - `:acq_time` - `float`/`milliseconds` - time spent on lock acquiring;
545
+ - `:meta` - `nil`/`Any` - custom metadata passed to the `lock`/`lock!` method;
539
546
  - `"redis_queued_locks.lock_hold_and_release"`
540
547
  - an event signalizes about the "hold+and+release" process
541
548
  when the lock obtained and hold by the block of logic;
@@ -546,6 +553,7 @@ Detalized event semantics and payload structure:
546
553
  - `:lock_key` - `string` - lock name;
547
554
  - `:ts` - `integer`/`epoch` - the time when lock was obtained;
548
555
  - `:acq_time` - `float`/`milliseconds` - time spent on lock acquiring;
556
+ - `:meta` - `nil`/`Any` - custom metadata passed to the `lock`/`lock!` method;
549
557
  - `"redis_queued_locks.explicit_lock_release"`
550
558
  - an event signalizes about the explicit lock release (invoked via `RedisQueuedLock#unlock`);
551
559
  - payload:
@@ -571,6 +579,7 @@ Detalized event semantics and payload structure:
571
579
  the acquired lock for long-running blocks of code (that invoked "under" the lock
572
580
  whose ttl may expire before the block execution completes);
573
581
  - an ability to add custom metadata to the lock and an ability to read this data;
582
+ - lock prioritization;
574
583
  - **Minor**
575
584
  - GitHub Actions CI;
576
585
  - `RedisQueuedLocks::Acquier::Try.try_to_lock` - detailed successful result analization;
@@ -63,6 +63,8 @@ module RedisQueuedLocks::Acquier
63
63
  # @option fail_fast [Boolean]
64
64
  # Should the required lock to be checked before the try and exit immidetly if lock is
65
65
  # already obtained.
66
+ # @option metadata [NilClass,Any]
67
+ # - A custom metadata wich will be passed to the instrumenter's payload with :meta key;
66
68
  # @param [Block]
67
69
  # A block of code that should be executed after the successfully acquired lock.
68
70
  # @return [RedisQueuedLocks::Data,Hash<Symbol,Any>,yield]
@@ -90,6 +92,7 @@ module RedisQueuedLocks::Acquier
90
92
  instrumenter:,
91
93
  identity:,
92
94
  fail_fast:,
95
+ metadata:,
93
96
  &block
94
97
  )
95
98
  # Step 1: prepare lock requirements (generate lock name, calc lock ttl, etc).
@@ -153,7 +156,8 @@ module RedisQueuedLocks::Acquier
153
156
  ttl: result[:ttl],
154
157
  acq_id: result[:acq_id],
155
158
  ts: result[:ts],
156
- acq_time: acq_time
159
+ acq_time: acq_time,
160
+ meta: metadata
157
161
  })
158
162
 
159
163
  # Step 2.1.a: successfully acquired => build the result
@@ -233,7 +237,8 @@ module RedisQueuedLocks::Acquier
233
237
  acq_id: acq_process[:lock_info][:acq_id],
234
238
  ts: acq_process[:lock_info][:ts],
235
239
  lock_key: acq_process[:lock_info][:lock_key],
236
- acq_time: acq_process[:acq_time]
240
+ acq_time: acq_process[:acq_time],
241
+ meta: metadata
237
242
  })
238
243
  end
239
244
  end
@@ -92,6 +92,8 @@ class RedisQueuedLocks::Client
92
92
  # already obtained;
93
93
  # - Should the logic exit immidietly after the first try if the lock was obtained
94
94
  # by another process while the lock request queue was initially empty;
95
+ # @option metadata [NilClass,Any]
96
+ # - A custom metadata wich will be passed to the instrumenter's payload with :meta key;
95
97
  # @param block [Block]
96
98
  # A block of code that should be executed after the successfully acquired lock.
97
99
  # @return [RedisQueuedLocks::Data,Hash<Symbol,Any>,yield]
@@ -112,6 +114,7 @@ class RedisQueuedLocks::Client
112
114
  raise_errors: false,
113
115
  fail_fast: false,
114
116
  identity: uniq_identity,
117
+ metadata: nil,
115
118
  &block
116
119
  )
117
120
  RedisQueuedLocks::Acquier.acquire_lock!(
@@ -132,6 +135,7 @@ class RedisQueuedLocks::Client
132
135
  instrumenter: config[:instrumenter],
133
136
  identity:,
134
137
  fail_fast:,
138
+ metadata:,
135
139
  &block
136
140
  )
137
141
  end
@@ -151,6 +155,7 @@ class RedisQueuedLocks::Client
151
155
  retry_jitter: config[:retry_jitter],
152
156
  fail_fast: false,
153
157
  identity: uniq_identity,
158
+ metadata: nil,
154
159
  &block
155
160
  )
156
161
  lock(
@@ -165,6 +170,7 @@ class RedisQueuedLocks::Client
165
170
  raise_errors: true,
166
171
  identity:,
167
172
  fail_fast:,
173
+ metadata:,
168
174
  &block
169
175
  )
170
176
  end
@@ -5,6 +5,6 @@ module RedisQueuedLocks
5
5
  #
6
6
  # @api public
7
7
  # @since 0.0.1
8
- # @version 0.0.19
9
- VERSION = '0.0.19'
8
+ # @version 0.0.20
9
+ VERSION = '0.0.20'
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.19
4
+ version: 0.0.20
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-12 00:00:00.000000000 Z
11
+ date: 2024-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client