redis_queued_locks 1.10.0 → 1.12.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/redis_queued_locks/acquier/acquire_lock/with_acq_timeout.rb +9 -3
- data/lib/redis_queued_locks/acquier/acquire_lock/yield_expire.rb +6 -12
- data/lib/redis_queued_locks/errors.rb +8 -0
- data/lib/redis_queued_locks/version.rb +2 -2
- data/lib/redis_queued_locks.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e8dd94852534ed373615917be290e53b29e203e7b88907d24631869ab4f2deb
|
4
|
+
data.tar.gz: 9b78929772d22f8ae6cbb628d306a85c44d4eec2f6a41e68bccfa0d754db80b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14e6e0c7ff71c9bc0d8a4ff1088a0b9983a8bd365fa10b17236996b3cb20e291fb951e648c79430b2d4091179024385648a343b36913443a9459c3c9e2a71b18
|
7
|
+
data.tar.gz: f0aa55c8561513a87d3c8f347db2f9a0710c62b4fe6d03fd6b512fec56c2631da77b86080bbbdf051bfc82d6abe2016f8baf37e43b3eebc973bd404bb7f80a35
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.12.0] - 2024-08-11
|
4
|
+
### Changed
|
5
|
+
- Timed blocks of code and their timeout errors: reduced error message object allocations;
|
6
|
+
|
7
|
+
## [1.11.0] - 2024-08-11
|
8
|
+
### Changed
|
9
|
+
- Lock Acquierment Timeout (`acq_timeout`/`queue_ttl`): more correct timeout error interception
|
10
|
+
inside the `RedisQueuedLocks::Acquier::AcquireLock::WithAcqTimeout` logic that now raises and
|
11
|
+
intercepts an internal timeout error class in order to prevent interceptions of
|
12
|
+
other timeouts that can be raised from the wrapped block of code;
|
13
|
+
|
3
14
|
## [1.10.0] - 2024-08-11
|
4
15
|
### Changed
|
5
16
|
- Timed invocations (`"timeed blocks of code"` / `timed: true`):
|
@@ -8,6 +19,8 @@
|
|
8
19
|
now uses `Timeout#timeout`'s custom exception class/message replacement API;
|
9
20
|
- `rescue Timeout::Error` can lead to incorrect exception interception: intercept block's-related
|
10
21
|
Timeout::Error that is not RQL-related error;
|
22
|
+
- Updated development dependencies;
|
23
|
+
- Some minor readme updates;
|
11
24
|
### Added
|
12
25
|
- `RedisQueuedLocks::Swarm`: missing YARDocs;
|
13
26
|
- Separated `Logging Configuration` readme section (that is placed inside the main configuration section already);
|
@@ -19,9 +19,11 @@ module RedisQueuedLocks::Acquier::AcquireLock::WithAcqTimeout
|
|
19
19
|
# Callback invoked on Timeout::Error.
|
20
20
|
# @return [Any]
|
21
21
|
#
|
22
|
+
# @raise [RedisQueuedLocks::LockAcquiermentIntermediateTimeoutError]
|
23
|
+
#
|
22
24
|
# @api private
|
23
25
|
# @since 1.0.0
|
24
|
-
# @version 1.
|
26
|
+
# @version 1.11.0
|
25
27
|
def with_acq_timeout(
|
26
28
|
redis,
|
27
29
|
timeout,
|
@@ -32,8 +34,12 @@ module RedisQueuedLocks::Acquier::AcquireLock::WithAcqTimeout
|
|
32
34
|
on_timeout: nil,
|
33
35
|
&block
|
34
36
|
)
|
35
|
-
|
36
|
-
|
37
|
+
# TODO:
|
38
|
+
# think about the runtime error class-object creation that perevent any timeout error
|
39
|
+
# interception collisions (but remember: it can lead to regular internal ruby method/constant
|
40
|
+
# cache invalidation);
|
41
|
+
::Timeout.timeout(timeout, RedisQueuedLocks::LockAcquiermentIntermediateTimeoutError, &block)
|
42
|
+
rescue RedisQueuedLocks::LockAcquiermentIntermediateTimeoutError
|
37
43
|
on_timeout.call unless on_timeout == nil
|
38
44
|
|
39
45
|
if raise_errors
|
@@ -107,28 +107,22 @@ module RedisQueuedLocks::Acquier::AcquireLock::YieldExpire
|
|
107
107
|
# @param block [Blcok]
|
108
108
|
# @return [Any]
|
109
109
|
#
|
110
|
+
# @raise [RedisQueuedLocks::TimedLockTimeoutError]
|
111
|
+
#
|
110
112
|
# @api private
|
111
113
|
# @since 1.3.0
|
112
|
-
# @version 1.
|
114
|
+
# @version 1.12.0
|
113
115
|
def yield_with_timeout(timeout, lock_key, lock_ttl, acquier_id, host_id, meta, &block)
|
114
|
-
::Timeout.timeout(
|
115
|
-
|
116
|
+
::Timeout.timeout(timeout, RedisQueuedLocks::TimedLockIntermediateTimeoutError, &block)
|
117
|
+
rescue RedisQueuedLocks::TimedLockIntermediateTimeoutError
|
118
|
+
raise(
|
116
119
|
RedisQueuedLocks::TimedLockTimeoutError,
|
117
|
-
# NOTE:
|
118
|
-
# - this string is generated on each invocation cuz we need to raise custom exception
|
119
|
-
# from the Timeout API in order to prevent incorred Timeout::Error interception when
|
120
|
-
# the intercepted error is caused from the block not from the RQL;
|
121
|
-
# - we can't omit this string object creation at the moment via original Ruby's Timeout API;
|
122
|
-
# TODO:
|
123
|
-
# - refine Timeout#timeout (via Ruby's Refinement API) in order to provide lazy exception
|
124
|
-
# message initialization;
|
125
120
|
"Passed <timed> block of code exceeded the lock TTL " \
|
126
121
|
"(lock: \"#{lock_key}\", " \
|
127
122
|
"ttl: #{lock_ttl}, " \
|
128
123
|
"meta: #{meta ? meta.inspect : '<no-meta>'}, " \
|
129
124
|
"acq_id: \"#{acquier_id}\", " \
|
130
125
|
"hst_id: \"#{host_id}\")",
|
131
|
-
&block
|
132
126
|
)
|
133
127
|
end
|
134
128
|
end
|
@@ -13,6 +13,10 @@ module RedisQueuedLocks
|
|
13
13
|
# @since 1.0.0
|
14
14
|
LockAlreadyObtainedError = Class.new(Error)
|
15
15
|
|
16
|
+
# @api private
|
17
|
+
# @since 1.11.0
|
18
|
+
LockAcquiermentIntermediateTimeoutError = Class.new(::Timeout::Error)
|
19
|
+
|
16
20
|
# @api public
|
17
21
|
# @since 1.0.0
|
18
22
|
LockAcquiermentTimeoutError = Class.new(Error)
|
@@ -21,6 +25,10 @@ module RedisQueuedLocks
|
|
21
25
|
# @since 1.0.0
|
22
26
|
LockAcquiermentRetryLimitError = Class.new(Error)
|
23
27
|
|
28
|
+
# @api private
|
29
|
+
# @since 1.12.0
|
30
|
+
TimedLockIntermediateTimeoutError = Class.new(::Timeout::Error)
|
31
|
+
|
24
32
|
# @api pulic
|
25
33
|
# @since 1.0.0
|
26
34
|
TimedLockTimeoutError = Class.new(Error)
|
data/lib/redis_queued_locks.rb
CHANGED
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: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
|
-
rubygems_version: 3.5.
|
138
|
+
rubygems_version: 3.5.17
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Distributed locks with "prioritized lock acquisition queue" capabilities
|