redis_queued_locks 1.22.0 → 1.23.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/.claude/project-overview.md +88 -36
- data/.claude/rules/acquirer.md +11 -7
- data/.claude/rules/arguments.md +2 -2
- data/.claude/rules/logic.md +5 -4
- data/.claude/rules/tests.md +4 -4
- data/.claude/rules/type-checking.md +2 -3
- data/.claude/rules/visitors.md +8 -6
- data/.claude/skills/rql-code-review/SKILL.md +25 -20
- data/.ruby-version +1 -1
- data/CHANGELOG.md +24 -1
- data/CLAUDE.md +5 -4
- data/README.md +247 -96
- data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb +4 -4
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb +582 -276
- data/lib/redis_queued_locks/acquirer/acquire_lock.rb +26 -26
- data/lib/redis_queued_locks/acquirer/extend_lock_ttl.rb +13 -13
- data/lib/redis_queued_locks/acquirer/lock_series/instr_visitor.rb +243 -0
- data/lib/redis_queued_locks/acquirer/lock_series/log_visitor.rb +472 -0
- data/lib/redis_queued_locks/acquirer/lock_series/release_lock_series.rb +181 -0
- data/lib/redis_queued_locks/acquirer/lock_series/try_to_lock_series.rb +1051 -0
- data/lib/redis_queued_locks/acquirer/lock_series.rb +948 -0
- data/lib/redis_queued_locks/acquirer.rb +1 -1
- data/lib/redis_queued_locks/client.rb +55 -25
- data/lib/redis_queued_locks/version.rb +2 -2
- data/redis_queued_locks.gemspec +21 -14
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +1 -1
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +106 -5
- data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +1 -1
- data/sig/redis_queued_locks/acquirer/extend_lock_ttl.rbs +2 -2
- data/sig/redis_queued_locks/acquirer/lock_series/instr_visitor.rbs +102 -0
- data/sig/redis_queued_locks/acquirer/lock_series/log_visitor.rbs +154 -0
- data/sig/redis_queued_locks/acquirer/lock_series/release_lock_series.rbs +37 -0
- data/sig/redis_queued_locks/acquirer/lock_series/try_to_lock_series.rbs +198 -0
- data/sig/redis_queued_locks/acquirer/lock_series.rbs +106 -0
- data/sig/redis_queued_locks/client.rbs +70 -3
- metadata +32 -11
- data/lib/redis_queued_locks/acquirer/lock_series_poc/instr_visitor.rb +0 -61
- data/lib/redis_queued_locks/acquirer/lock_series_poc/log_visitor.rb +0 -104
- data/lib/redis_queued_locks/acquirer/lock_series_poc.rb +0 -513
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
use RedisQueuedLocks as RQL
|
|
2
|
+
|
|
3
|
+
module RedisQueuedLocks
|
|
4
|
+
module Acquirer
|
|
5
|
+
module LockSeries
|
|
6
|
+
module LogVisitor
|
|
7
|
+
def self.start_lock_series_obtaining: (
|
|
8
|
+
RQL::loggerObj logger,
|
|
9
|
+
bool log_sampled,
|
|
10
|
+
Array[String] lock_keys,
|
|
11
|
+
Integer queue_ttl,
|
|
12
|
+
String acquirer_id,
|
|
13
|
+
String host_id,
|
|
14
|
+
RQL::accessStrategy access_strategy,
|
|
15
|
+
RQL::readWriteMode rw_mode,
|
|
16
|
+
Integer priority
|
|
17
|
+
) -> void
|
|
18
|
+
|
|
19
|
+
def self.start_try_to_lock_series_cycle: (
|
|
20
|
+
RQL::loggerObj logger,
|
|
21
|
+
bool log_sampled,
|
|
22
|
+
Array[String] lock_keys,
|
|
23
|
+
Integer queue_ttl,
|
|
24
|
+
String acquirer_id,
|
|
25
|
+
String host_id,
|
|
26
|
+
RQL::accessStrategy access_strategy,
|
|
27
|
+
RQL::readWriteMode rw_mode,
|
|
28
|
+
Integer priority
|
|
29
|
+
) -> void
|
|
30
|
+
|
|
31
|
+
def self.dead_score_reached__reset_series_position: (
|
|
32
|
+
RQL::loggerObj logger,
|
|
33
|
+
bool log_sampled,
|
|
34
|
+
Array[String] lock_keys,
|
|
35
|
+
Integer queue_ttl,
|
|
36
|
+
String acquirer_id,
|
|
37
|
+
String host_id,
|
|
38
|
+
RQL::accessStrategy access_strategy,
|
|
39
|
+
RQL::readWriteMode rw_mode,
|
|
40
|
+
Integer priority
|
|
41
|
+
) -> void
|
|
42
|
+
|
|
43
|
+
def self.dequeue_from_lock_series_queues: (
|
|
44
|
+
RQL::loggerObj logger,
|
|
45
|
+
bool log_sampled,
|
|
46
|
+
Array[String] lock_keys,
|
|
47
|
+
Integer queue_ttl,
|
|
48
|
+
String acquirer_id,
|
|
49
|
+
String host_id,
|
|
50
|
+
RQL::accessStrategy access_strategy,
|
|
51
|
+
RQL::readWriteMode rw_mode,
|
|
52
|
+
Integer priority
|
|
53
|
+
) -> void
|
|
54
|
+
|
|
55
|
+
def self.expire_lock_series: (
|
|
56
|
+
RQL::loggerObj logger,
|
|
57
|
+
bool log_sampled,
|
|
58
|
+
Array[String] lock_keys,
|
|
59
|
+
Integer queue_ttl,
|
|
60
|
+
String acquirer_id,
|
|
61
|
+
String host_id,
|
|
62
|
+
RQL::accessStrategy access_strategy,
|
|
63
|
+
RQL::readWriteMode rw_mode,
|
|
64
|
+
Integer priority
|
|
65
|
+
) -> void
|
|
66
|
+
|
|
67
|
+
def self.lock_series_intermediate_lock_obtained: (
|
|
68
|
+
RQL::loggerObj logger,
|
|
69
|
+
bool log_sampled,
|
|
70
|
+
String lock_key,
|
|
71
|
+
Array[String] lock_keys,
|
|
72
|
+
Integer queue_ttl,
|
|
73
|
+
String acquirer_id,
|
|
74
|
+
String host_id,
|
|
75
|
+
Integer|Float acq_time,
|
|
76
|
+
RQL::accessStrategy access_strategy,
|
|
77
|
+
RQL::readWriteMode rw_mode,
|
|
78
|
+
Integer priority
|
|
79
|
+
) -> void
|
|
80
|
+
|
|
81
|
+
def self.lock_series_lock_obtained: (
|
|
82
|
+
RQL::loggerObj logger,
|
|
83
|
+
bool log_sampled,
|
|
84
|
+
String lock_key,
|
|
85
|
+
Array[String] lock_keys,
|
|
86
|
+
Integer queue_ttl,
|
|
87
|
+
String acquirer_id,
|
|
88
|
+
String host_id,
|
|
89
|
+
Integer|Float acq_time,
|
|
90
|
+
RQL::accessStrategy access_strategy,
|
|
91
|
+
RQL::readWriteMode rw_mode,
|
|
92
|
+
Integer priority
|
|
93
|
+
) -> void
|
|
94
|
+
|
|
95
|
+
def self.lock_series_lock_obtaining_failed: (
|
|
96
|
+
RQL::loggerObj logger,
|
|
97
|
+
bool log_sampled,
|
|
98
|
+
String lock_key,
|
|
99
|
+
Array[String] lock_keys,
|
|
100
|
+
Integer queue_ttl,
|
|
101
|
+
String acquirer_id,
|
|
102
|
+
String host_id,
|
|
103
|
+
Integer|Float acq_time,
|
|
104
|
+
RQL::accessStrategy access_strategy,
|
|
105
|
+
RQL::readWriteMode rw_mode,
|
|
106
|
+
Integer priority,
|
|
107
|
+
Symbol result
|
|
108
|
+
) -> void
|
|
109
|
+
|
|
110
|
+
def self.lock_series_obtained: (
|
|
111
|
+
RQL::loggerObj logger,
|
|
112
|
+
bool log_sampled,
|
|
113
|
+
Array[String] lock_keys,
|
|
114
|
+
Integer queue_ttl,
|
|
115
|
+
String acquirer_id,
|
|
116
|
+
String host_id,
|
|
117
|
+
Integer|Float acq_time,
|
|
118
|
+
RQL::accessStrategy access_strategy,
|
|
119
|
+
RQL::readWriteMode rw_mode,
|
|
120
|
+
Integer priority,
|
|
121
|
+
Array[String] reentrant_lock_keys
|
|
122
|
+
) -> void
|
|
123
|
+
|
|
124
|
+
def self.lock_series_obtaining_failed: (
|
|
125
|
+
RQL::loggerObj logger,
|
|
126
|
+
bool log_sampled,
|
|
127
|
+
Array[String] lock_keys,
|
|
128
|
+
Integer queue_ttl,
|
|
129
|
+
String acquirer_id,
|
|
130
|
+
String host_id,
|
|
131
|
+
Integer|Float acq_time,
|
|
132
|
+
RQL::accessStrategy access_strategy,
|
|
133
|
+
RQL::readWriteMode rw_mode,
|
|
134
|
+
Integer priority,
|
|
135
|
+
Symbol result,
|
|
136
|
+
String? failed_lock_key
|
|
137
|
+
) -> void
|
|
138
|
+
|
|
139
|
+
def self.decrease_lock_series: (
|
|
140
|
+
RQL::loggerObj logger,
|
|
141
|
+
bool log_sampled,
|
|
142
|
+
Array[String] lock_keys,
|
|
143
|
+
Integer decreased_ttl,
|
|
144
|
+
Integer queue_ttl,
|
|
145
|
+
String acquirer_id,
|
|
146
|
+
String host_id,
|
|
147
|
+
RQL::accessStrategy access_strategy,
|
|
148
|
+
RQL::readWriteMode rw_mode,
|
|
149
|
+
Integer priority
|
|
150
|
+
) -> void
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
use RedisQueuedLocks as RQL
|
|
2
|
+
use RedisClient as RC
|
|
3
|
+
|
|
4
|
+
module RedisQueuedLocks
|
|
5
|
+
module Acquirer
|
|
6
|
+
module LockSeries
|
|
7
|
+
module ReleaseLockSeries
|
|
8
|
+
def release_lock_series: (
|
|
9
|
+
RC::client redis,
|
|
10
|
+
Array[String] lock_names,
|
|
11
|
+
Array[Symbol?] lock_processes,
|
|
12
|
+
Array[RQL::readWriteMode] held_rw_modes,
|
|
13
|
+
String acquirer_id,
|
|
14
|
+
Integer decreased_ttl
|
|
15
|
+
) -> void
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def release_write_lock_series: (
|
|
20
|
+
RC::client redis,
|
|
21
|
+
Array[String] lock_names,
|
|
22
|
+
Array[String] extended_lock_names,
|
|
23
|
+
String acquirer_id,
|
|
24
|
+
Integer decreased_ttl
|
|
25
|
+
) -> void
|
|
26
|
+
|
|
27
|
+
def release_read_lock_series: (
|
|
28
|
+
RC::client redis,
|
|
29
|
+
Array[String] lock_names,
|
|
30
|
+
Array[String] extended_lock_names,
|
|
31
|
+
String acquirer_id,
|
|
32
|
+
Integer decreased_ttl
|
|
33
|
+
) -> void
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
use RedisQueuedLocks as RQL
|
|
2
|
+
use RedisClient as RC
|
|
3
|
+
|
|
4
|
+
module RedisQueuedLocks
|
|
5
|
+
module Acquirer
|
|
6
|
+
module LockSeries
|
|
7
|
+
module TryToLockSeries
|
|
8
|
+
include RQL::Acquirer::AcquireLock::TryToLock
|
|
9
|
+
include RQL::Acquirer::LockSeries::ReleaseLockSeries
|
|
10
|
+
|
|
11
|
+
type attemptResult = { ok: bool, result: Symbol, lock_name: String?, ready_locks: Array[Integer] }
|
|
12
|
+
type seriesObstacle = [Symbol, Integer]
|
|
13
|
+
type deadRequests = [Integer, [[String, Float]?, Integer?, [String, Float]?, Integer?]]
|
|
14
|
+
type lockState = {
|
|
15
|
+
obtainer: String?,
|
|
16
|
+
redis_time: Integer,
|
|
17
|
+
own_read_lock_expiration: Float?,
|
|
18
|
+
read_locked: bool,
|
|
19
|
+
conflict_rw_mode: RQL::readWriteMode?,
|
|
20
|
+
queued: bool,
|
|
21
|
+
waiting_request: [String, Float]?,
|
|
22
|
+
opposite_waiting_request: [String, Float]?,
|
|
23
|
+
dropped_requests: Array[[String, Integer]]?
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def try_to_lock_series: (
|
|
27
|
+
RC::client redis,
|
|
28
|
+
RQL::loggerObj logger,
|
|
29
|
+
bool log_lock_try,
|
|
30
|
+
Array[String] lock_keys,
|
|
31
|
+
RQL::readWriteMode rw_mode,
|
|
32
|
+
Array[String] lock_key_queues,
|
|
33
|
+
Array[String] read_lock_key_queues,
|
|
34
|
+
Array[String] lock_readers_keys,
|
|
35
|
+
Array[String?] read_lock_keys,
|
|
36
|
+
Array[String] lock_names,
|
|
37
|
+
Array[String] watched_keys,
|
|
38
|
+
String acquirer_id,
|
|
39
|
+
String host_id,
|
|
40
|
+
Integer|Float acquirer_position,
|
|
41
|
+
Integer priority,
|
|
42
|
+
Integer ttl,
|
|
43
|
+
Integer queue_ttl,
|
|
44
|
+
bool lock_index_enabled,
|
|
45
|
+
Integer lock_index_grace_period,
|
|
46
|
+
bool fail_fast,
|
|
47
|
+
RQL::conflictStrategy conflict_strategy,
|
|
48
|
+
RQL::accessStrategy access_strategy,
|
|
49
|
+
Hash[String|Symbol,untyped]? meta,
|
|
50
|
+
bool retry_attempt,
|
|
51
|
+
Hash[Symbol,untyped] acq_process,
|
|
52
|
+
bool log_sampled
|
|
53
|
+
) -> attemptResult
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def pipeline_series_lock_state: (
|
|
58
|
+
RedisClient::Pipeline pipeline,
|
|
59
|
+
Array[String] lock_keys,
|
|
60
|
+
Array[String] lock_readers_keys,
|
|
61
|
+
String acquirer_id,
|
|
62
|
+
bool read_mode,
|
|
63
|
+
bool queueing,
|
|
64
|
+
Array[String] request_queues,
|
|
65
|
+
Array[String] opposite_request_queues,
|
|
66
|
+
Integer|Float acquirer_position,
|
|
67
|
+
Integer priority,
|
|
68
|
+
Float acquirer_dead_score,
|
|
69
|
+
Array[String] lock_names,
|
|
70
|
+
Integer queue_ttl,
|
|
71
|
+
bool lock_index_enabled,
|
|
72
|
+
Integer lock_index_grace_period
|
|
73
|
+
) -> void
|
|
74
|
+
|
|
75
|
+
def series_lock_state_replies: (
|
|
76
|
+
bool read_mode,
|
|
77
|
+
bool queueing,
|
|
78
|
+
bool lock_index_enabled
|
|
79
|
+
) -> Integer
|
|
80
|
+
|
|
81
|
+
def series_queue_replies: (bool lock_index_enabled) -> Integer
|
|
82
|
+
|
|
83
|
+
def series_lock_states: (
|
|
84
|
+
Array[untyped] state_replies,
|
|
85
|
+
Integer locks_count,
|
|
86
|
+
String acquirer_id,
|
|
87
|
+
bool read_mode,
|
|
88
|
+
bool queueing,
|
|
89
|
+
bool lock_index_enabled
|
|
90
|
+
) -> Array[lockState]
|
|
91
|
+
|
|
92
|
+
def queue_series_lock_requests: (
|
|
93
|
+
RC::client rconn,
|
|
94
|
+
Array[lockState] lock_states,
|
|
95
|
+
Array[Symbol?] lock_processes,
|
|
96
|
+
Array[String] request_queues,
|
|
97
|
+
Array[String] opposite_request_queues,
|
|
98
|
+
Integer|Float acquirer_position,
|
|
99
|
+
Integer priority,
|
|
100
|
+
String acquirer_id,
|
|
101
|
+
Float acquirer_dead_score,
|
|
102
|
+
Array[String] lock_names,
|
|
103
|
+
Integer queue_ttl,
|
|
104
|
+
bool lock_index_enabled,
|
|
105
|
+
Integer lock_index_grace_period
|
|
106
|
+
) -> void
|
|
107
|
+
|
|
108
|
+
def drop_series_dead_requests_ahead: (
|
|
109
|
+
RC::client rconn,
|
|
110
|
+
bool read_mode,
|
|
111
|
+
Array[String] request_queues,
|
|
112
|
+
Array[String] opposite_request_queues,
|
|
113
|
+
Array[lockState] lock_states,
|
|
114
|
+
String acquirer_id,
|
|
115
|
+
Integer|Float acquirer_position,
|
|
116
|
+
Float acquirer_dead_score,
|
|
117
|
+
RQL::accessStrategy access_strategy
|
|
118
|
+
) -> void
|
|
119
|
+
|
|
120
|
+
def find_series_lock_obstacle: (
|
|
121
|
+
Array[lockState] lock_states,
|
|
122
|
+
bool read_mode,
|
|
123
|
+
RQL::accessStrategy access_strategy,
|
|
124
|
+
String acquirer_id,
|
|
125
|
+
Integer|Float acquirer_position,
|
|
126
|
+
Array[Integer] ready_locks
|
|
127
|
+
) -> seriesObstacle?
|
|
128
|
+
|
|
129
|
+
def log_series_queueing: (
|
|
130
|
+
RQL::loggerObj logger,
|
|
131
|
+
bool log_sampled,
|
|
132
|
+
bool log_lock_try,
|
|
133
|
+
Array[String] lock_keys,
|
|
134
|
+
Array[lockState] lock_states,
|
|
135
|
+
Integer queue_ttl,
|
|
136
|
+
String acquirer_id,
|
|
137
|
+
String host_id,
|
|
138
|
+
RQL::accessStrategy access_strategy,
|
|
139
|
+
RQL::readWriteMode rw_mode,
|
|
140
|
+
Integer priority
|
|
141
|
+
) -> void
|
|
142
|
+
|
|
143
|
+
def log_series_dropped_requests: (
|
|
144
|
+
RQL::loggerObj logger,
|
|
145
|
+
bool log_sampled,
|
|
146
|
+
bool log_lock_try,
|
|
147
|
+
Array[String] lock_keys,
|
|
148
|
+
Array[lockState] lock_states,
|
|
149
|
+
Integer queue_ttl,
|
|
150
|
+
String acquirer_id,
|
|
151
|
+
String host_id,
|
|
152
|
+
RQL::accessStrategy access_strategy,
|
|
153
|
+
RQL::readWriteMode rw_mode
|
|
154
|
+
) -> void
|
|
155
|
+
|
|
156
|
+
def log_series_lock_obstacle: (
|
|
157
|
+
RC::client rconn,
|
|
158
|
+
Symbol obstacle,
|
|
159
|
+
Integer lock_index,
|
|
160
|
+
Array[lockState] lock_states,
|
|
161
|
+
RQL::loggerObj logger,
|
|
162
|
+
bool log_sampled,
|
|
163
|
+
bool log_lock_try,
|
|
164
|
+
Array[String] lock_keys,
|
|
165
|
+
Integer queue_ttl,
|
|
166
|
+
String acquirer_id,
|
|
167
|
+
String host_id,
|
|
168
|
+
RQL::accessStrategy access_strategy,
|
|
169
|
+
RQL::readWriteMode rw_mode
|
|
170
|
+
) -> void
|
|
171
|
+
|
|
172
|
+
def precheck_lock_series: (
|
|
173
|
+
RC::client rconn,
|
|
174
|
+
RQL::loggerObj logger,
|
|
175
|
+
bool log_sampled,
|
|
176
|
+
bool log_lock_try,
|
|
177
|
+
Array[String] lock_keys,
|
|
178
|
+
RQL::readWriteMode rw_mode,
|
|
179
|
+
Array[String] lock_readers_keys,
|
|
180
|
+
Array[String] request_queues,
|
|
181
|
+
Array[String] opposite_request_queues,
|
|
182
|
+
Array[String] lock_names,
|
|
183
|
+
String acquirer_id,
|
|
184
|
+
String host_id,
|
|
185
|
+
Integer|Float acquirer_position,
|
|
186
|
+
Integer priority,
|
|
187
|
+
Float acquirer_dead_score,
|
|
188
|
+
Integer queue_ttl,
|
|
189
|
+
bool lock_index_enabled,
|
|
190
|
+
Integer lock_index_grace_period,
|
|
191
|
+
bool fail_fast,
|
|
192
|
+
RQL::accessStrategy access_strategy,
|
|
193
|
+
Array[Integer] ready_locks
|
|
194
|
+
) -> seriesObstacle?
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
use RedisQueuedLocks as RQL
|
|
2
|
+
use RedisClient as RC
|
|
3
|
+
|
|
4
|
+
module RedisQueuedLocks
|
|
5
|
+
module Acquirer
|
|
6
|
+
module LockSeries
|
|
7
|
+
extend RQL::Utilities
|
|
8
|
+
extend RQL::Acquirer::AcquireLock::DelayExecution
|
|
9
|
+
extend RQL::Acquirer::AcquireLock::YieldExpire
|
|
10
|
+
extend RQL::Acquirer::LockSeries::TryToLockSeries
|
|
11
|
+
|
|
12
|
+
type lockSeriesResult = ({ ok: bool, result: untyped }|untyped)
|
|
13
|
+
def self.lock_series: (
|
|
14
|
+
RC::client redis,
|
|
15
|
+
Array[String] lock_names,
|
|
16
|
+
detailed_result: bool,
|
|
17
|
+
process_id: Integer|String,
|
|
18
|
+
thread_id: Integer|String,
|
|
19
|
+
fiber_id: Integer|String,
|
|
20
|
+
ractor_id: Integer|String,
|
|
21
|
+
ttl: Integer,
|
|
22
|
+
queue_ttl: Integer,
|
|
23
|
+
lock_index_enabled: bool,
|
|
24
|
+
lock_index_grace_period: Integer,
|
|
25
|
+
timeout: Integer?,
|
|
26
|
+
timed: bool,
|
|
27
|
+
retry_count: Integer?,
|
|
28
|
+
retry_delay: Integer,
|
|
29
|
+
retry_jitter: Integer,
|
|
30
|
+
raise_errors: bool,
|
|
31
|
+
instrumenter: RQL::instrObj,
|
|
32
|
+
identity: String,
|
|
33
|
+
fail_fast: bool,
|
|
34
|
+
meta: Hash[String|Symbol,untyped]?,
|
|
35
|
+
detailed_acq_timeout_error: bool,
|
|
36
|
+
instrument: untyped?,
|
|
37
|
+
logger: RQL::loggerObj,
|
|
38
|
+
log_lock_try: bool,
|
|
39
|
+
conflict_strategy: RQL::conflictStrategy,
|
|
40
|
+
rw_mode: Symbol, # NOTE: (rbs test) validated at runtime (Step 0.1 (RW)): any Symbol is accepted here
|
|
41
|
+
access_strategy: RQL::accessStrategy,
|
|
42
|
+
priority: RQL::lockPriority,
|
|
43
|
+
lock_priorities: Hash[Symbol, Integer],
|
|
44
|
+
log_sampling_enabled: bool,
|
|
45
|
+
log_sampling_percent: Integer,
|
|
46
|
+
log_sampler: RQL::Logging::samplerObj,
|
|
47
|
+
log_sample_this: bool,
|
|
48
|
+
instr_sampling_enabled: bool,
|
|
49
|
+
instr_sampling_percent: Integer,
|
|
50
|
+
instr_sampler: RQL::Instrument::samplerObj,
|
|
51
|
+
instr_sample_this: bool
|
|
52
|
+
) ?{ (?) -> untyped } -> lockSeriesResult
|
|
53
|
+
|
|
54
|
+
private def self.yield_lock_series: (
|
|
55
|
+
Array[String] lock_keys,
|
|
56
|
+
String acquirer_id,
|
|
57
|
+
String host_id,
|
|
58
|
+
bool timed,
|
|
59
|
+
Integer|Float ttl_shift,
|
|
60
|
+
Integer ttl,
|
|
61
|
+
Hash[String|Symbol,untyped]? meta
|
|
62
|
+
) ?{ (?) -> untyped } -> untyped?
|
|
63
|
+
|
|
64
|
+
private def self.complete_lock_series_release: (
|
|
65
|
+
RC::client redis,
|
|
66
|
+
Array[String] lock_names,
|
|
67
|
+
Array[Symbol?] lock_processes,
|
|
68
|
+
Array[RQL::readWriteMode] held_rw_modes,
|
|
69
|
+
String acquirer_id,
|
|
70
|
+
Integer decreased_ttl
|
|
71
|
+
) -> void
|
|
72
|
+
|
|
73
|
+
private def self.drop_failed_lock_series: (
|
|
74
|
+
RC::client redis,
|
|
75
|
+
RQL::loggerObj logger,
|
|
76
|
+
Array[String] lock_keys,
|
|
77
|
+
RQL::readWriteMode rw_mode,
|
|
78
|
+
Array[String] lock_key_queues,
|
|
79
|
+
Array[String] read_lock_key_queues,
|
|
80
|
+
Array[String] lock_names,
|
|
81
|
+
Integer queue_ttl,
|
|
82
|
+
String acquirer_id,
|
|
83
|
+
String host_id,
|
|
84
|
+
RQL::accessStrategy access_strategy,
|
|
85
|
+
Integer priority,
|
|
86
|
+
Hash[Symbol,untyped] acq_process,
|
|
87
|
+
bool log_sampled
|
|
88
|
+
) -> void
|
|
89
|
+
|
|
90
|
+
private def self.raise_lock_series_error: (
|
|
91
|
+
RC::client redis,
|
|
92
|
+
Symbol failure_result,
|
|
93
|
+
Array[String] lock_keys,
|
|
94
|
+
String? failed_lock_name,
|
|
95
|
+
String? failed_lock_key,
|
|
96
|
+
String acquirer_id,
|
|
97
|
+
RQL::conflictStrategy conflict_strategy,
|
|
98
|
+
Integer? retry_count,
|
|
99
|
+
Integer? timeout,
|
|
100
|
+
bool detailed_acq_timeout_error
|
|
101
|
+
) -> void
|
|
102
|
+
|
|
103
|
+
private def self.blocking_lock_details: (RC::client redis, String failed_lock_name) -> String
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -45,7 +45,7 @@ module RedisQueuedLocks
|
|
|
45
45
|
?raise_errors: bool,
|
|
46
46
|
?fail_fast: bool,
|
|
47
47
|
?conflict_strategy: RQL::conflictStrategy,
|
|
48
|
-
?
|
|
48
|
+
?rw_mode: RQL::readWriteMode,
|
|
49
49
|
?access_strategy: RQL::accessStrategy,
|
|
50
50
|
?priority: RQL::lockPriority,
|
|
51
51
|
?identity: String,
|
|
@@ -77,7 +77,7 @@ module RedisQueuedLocks
|
|
|
77
77
|
?retry_jitter: Integer,
|
|
78
78
|
?fail_fast: bool,
|
|
79
79
|
?conflict_strategy: RQL::conflictStrategy,
|
|
80
|
-
?
|
|
80
|
+
?rw_mode: RQL::readWriteMode,
|
|
81
81
|
?access_strategy: RQL::accessStrategy,
|
|
82
82
|
?priority: RQL::lockPriority,
|
|
83
83
|
?identity: String,
|
|
@@ -97,6 +97,73 @@ module RedisQueuedLocks
|
|
|
97
97
|
?instr_sample_this: bool,
|
|
98
98
|
) ?{ (?) -> untyped } -> RQL::Acquirer::AcquireLock::acquireResult
|
|
99
99
|
|
|
100
|
+
def lock_series: (
|
|
101
|
+
*String lock_names,
|
|
102
|
+
?detailed_result: bool,
|
|
103
|
+
?ttl: Integer,
|
|
104
|
+
?queue_ttl: Integer,
|
|
105
|
+
?lock_index_grace_period: Integer,
|
|
106
|
+
?timeout: Integer?,
|
|
107
|
+
?timed: bool,
|
|
108
|
+
?retry_count: Integer?,
|
|
109
|
+
?retry_delay: Integer,
|
|
110
|
+
?retry_jitter: Integer,
|
|
111
|
+
?raise_errors: bool,
|
|
112
|
+
?fail_fast: bool,
|
|
113
|
+
?conflict_strategy: RQL::conflictStrategy,
|
|
114
|
+
?rw_mode: RQL::readWriteMode,
|
|
115
|
+
?access_strategy: RQL::accessStrategy,
|
|
116
|
+
?priority: RQL::lockPriority,
|
|
117
|
+
?identity: String,
|
|
118
|
+
?meta: Hash[String|Symbol,untyped]?,
|
|
119
|
+
?detailed_acq_timeout_error: bool,
|
|
120
|
+
?logger: RQL::loggerObj,
|
|
121
|
+
?log_lock_try: bool,
|
|
122
|
+
?instrumenter: RQL::instrObj,
|
|
123
|
+
?instrument: untyped?,
|
|
124
|
+
?log_sampling_enabled: bool,
|
|
125
|
+
?log_sampling_percent: Integer,
|
|
126
|
+
?log_sampler: RQL::Logging::samplerObj,
|
|
127
|
+
?log_sample_this: bool,
|
|
128
|
+
?instr_sampling_enabled: bool,
|
|
129
|
+
?instr_sampling_percent: Integer,
|
|
130
|
+
?instr_sampler: RQL::Instrument::samplerObj,
|
|
131
|
+
?instr_sample_this: bool
|
|
132
|
+
) ?{ (?) -> untyped } -> RQL::Acquirer::LockSeries::lockSeriesResult
|
|
133
|
+
|
|
134
|
+
def lock_series!: (
|
|
135
|
+
*String lock_names,
|
|
136
|
+
?detailed_result: bool,
|
|
137
|
+
?ttl: Integer,
|
|
138
|
+
?queue_ttl: Integer,
|
|
139
|
+
?lock_index_grace_period: Integer,
|
|
140
|
+
?timeout: Integer?,
|
|
141
|
+
?timed: bool,
|
|
142
|
+
?retry_count: Integer?,
|
|
143
|
+
?retry_delay: Integer,
|
|
144
|
+
?retry_jitter: Integer,
|
|
145
|
+
?fail_fast: bool,
|
|
146
|
+
?conflict_strategy: RQL::conflictStrategy,
|
|
147
|
+
?rw_mode: RQL::readWriteMode,
|
|
148
|
+
?access_strategy: RQL::accessStrategy,
|
|
149
|
+
?priority: RQL::lockPriority,
|
|
150
|
+
?identity: String,
|
|
151
|
+
?meta: Hash[String|Symbol,untyped]?,
|
|
152
|
+
?detailed_acq_timeout_error: bool,
|
|
153
|
+
?logger: RQL::loggerObj,
|
|
154
|
+
?log_lock_try: bool,
|
|
155
|
+
?instrumenter: RQL::instrObj,
|
|
156
|
+
?instrument: untyped?,
|
|
157
|
+
?log_sampling_enabled: bool,
|
|
158
|
+
?log_sampling_percent: Integer,
|
|
159
|
+
?log_sampler: RQL::Logging::samplerObj,
|
|
160
|
+
?log_sample_this: bool,
|
|
161
|
+
?instr_sampling_enabled: bool,
|
|
162
|
+
?instr_sampling_percent: Integer,
|
|
163
|
+
?instr_sampler: RQL::Instrument::samplerObj,
|
|
164
|
+
?instr_sample_this: bool
|
|
165
|
+
) ?{ (?) -> untyped } -> RQL::Acquirer::LockSeries::lockSeriesResult
|
|
166
|
+
|
|
100
167
|
def unlock: (
|
|
101
168
|
String lock_name,
|
|
102
169
|
?logger: RQL::loggerObj,
|
|
@@ -160,7 +227,7 @@ module RedisQueuedLocks
|
|
|
160
227
|
def extend_lock_ttl: (
|
|
161
228
|
String lock_name,
|
|
162
229
|
Integer milliseconds,
|
|
163
|
-
?
|
|
230
|
+
?rw_mode: RQL::readWriteMode,
|
|
164
231
|
?all_read_locks: bool,
|
|
165
232
|
?identity: String,
|
|
166
233
|
?logger: RQL::loggerObj,
|
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.23.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rustam Ibragimov
|
|
@@ -23,12 +23,26 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0.20'
|
|
26
|
-
description:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
description: |
|
|
27
|
+
RedisQueuedLocks (aka RQL, aka RQL-lock) - distributed locks with
|
|
28
|
+
"prioritized lock acquisition queue" capabilities based on the Redis Database.
|
|
29
|
+
|
|
30
|
+
Each lock request is put into the request queue
|
|
31
|
+
(each lock is hosted by its own queue separately from other queues)
|
|
32
|
+
and processed in order of their priority: requests of a higher priority go first,
|
|
33
|
+
requests of the same priority are processed in FIFO order.
|
|
34
|
+
Each lock request lives some period of time (RTTL) (with requeue capabilities)
|
|
35
|
+
which guarantees the request queue will never be stacked.
|
|
36
|
+
|
|
37
|
+
In addition to the classic queued (FIFO) strategy RQL supports random (RANDOM)
|
|
38
|
+
lock obtaining strategy when any acquirer from the lock queue
|
|
39
|
+
can obtain the lock regardless the position in the queue.
|
|
40
|
+
|
|
41
|
+
Supports lock request prioritization, Read/Write locks and Reentrant locks.
|
|
42
|
+
|
|
43
|
+
Provides flexible invocation flow, parametrized limits (lock request ttl, lock ttl,
|
|
44
|
+
queue ttl, lock attempts limit, fast failing, etc), zombie locks elimination,
|
|
45
|
+
lock indexing, logging and instrumentation (and much more).
|
|
32
46
|
email:
|
|
33
47
|
- iamdaiver@gmail.com
|
|
34
48
|
executables: []
|
|
@@ -79,9 +93,11 @@ files:
|
|
|
79
93
|
- lib/redis_queued_locks/acquirer/is_queued.rb
|
|
80
94
|
- lib/redis_queued_locks/acquirer/keys.rb
|
|
81
95
|
- lib/redis_queued_locks/acquirer/lock_info.rb
|
|
82
|
-
- lib/redis_queued_locks/acquirer/
|
|
83
|
-
- lib/redis_queued_locks/acquirer/
|
|
84
|
-
- lib/redis_queued_locks/acquirer/
|
|
96
|
+
- lib/redis_queued_locks/acquirer/lock_series.rb
|
|
97
|
+
- lib/redis_queued_locks/acquirer/lock_series/instr_visitor.rb
|
|
98
|
+
- lib/redis_queued_locks/acquirer/lock_series/log_visitor.rb
|
|
99
|
+
- lib/redis_queued_locks/acquirer/lock_series/release_lock_series.rb
|
|
100
|
+
- lib/redis_queued_locks/acquirer/lock_series/try_to_lock_series.rb
|
|
85
101
|
- lib/redis_queued_locks/acquirer/locks.rb
|
|
86
102
|
- lib/redis_queued_locks/acquirer/queue_info.rb
|
|
87
103
|
- lib/redis_queued_locks/acquirer/queues.rb
|
|
@@ -141,6 +157,11 @@ files:
|
|
|
141
157
|
- sig/redis_queued_locks/acquirer/is_queued.rbs
|
|
142
158
|
- sig/redis_queued_locks/acquirer/keys.rbs
|
|
143
159
|
- sig/redis_queued_locks/acquirer/lock_info.rbs
|
|
160
|
+
- sig/redis_queued_locks/acquirer/lock_series.rbs
|
|
161
|
+
- sig/redis_queued_locks/acquirer/lock_series/instr_visitor.rbs
|
|
162
|
+
- sig/redis_queued_locks/acquirer/lock_series/log_visitor.rbs
|
|
163
|
+
- sig/redis_queued_locks/acquirer/lock_series/release_lock_series.rbs
|
|
164
|
+
- sig/redis_queued_locks/acquirer/lock_series/try_to_lock_series.rbs
|
|
144
165
|
- sig/redis_queued_locks/acquirer/locks.rbs
|
|
145
166
|
- sig/redis_queued_locks/acquirer/queue_info.rbs
|
|
146
167
|
- sig/redis_queued_locks/acquirer/queues.rbs
|
|
@@ -201,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
201
222
|
- !ruby/object:Gem::Version
|
|
202
223
|
version: '0'
|
|
203
224
|
requirements: []
|
|
204
|
-
rubygems_version: 4.0.
|
|
225
|
+
rubygems_version: 4.0.20
|
|
205
226
|
specification_version: 4
|
|
206
227
|
summary: Distributed locks with "prioritized lock acquisition queue" capabilities
|
|
207
228
|
based on the Redis Database.
|