redis_queued_locks 1.20.0 → 1.22.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 +249 -36
- data/.claude/rules/acquirer.md +16 -14
- data/.claude/rules/arguments.md +2 -2
- data/.claude/rules/changelog.md +27 -0
- data/.claude/rules/git.md +1 -1
- data/.claude/rules/logic.md +34 -13
- data/.claude/rules/swarm.md +4 -5
- data/.claude/rules/tests.md +9 -6
- data/.claude/rules/type-checking.md +13 -14
- data/.claude/rules/visitors.md +13 -14
- data/.claude/skills/rql-code-review/SKILL.md +134 -43
- data/CHANGELOG.md +105 -125
- data/CLAUDE.md +11 -9
- data/README.md +501 -136
- data/Rakefile +11 -0
- data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb +1 -0
- data/lib/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rb +68 -10
- data/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb +82 -15
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb +92 -14
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb +441 -63
- data/lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb +2 -2
- data/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb +1 -0
- data/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire.rb +5 -5
- data/lib/redis_queued_locks/acquirer/acquire_lock.rb +176 -39
- data/lib/redis_queued_locks/acquirer/clear_dead_requests.rb +322 -49
- data/lib/redis_queued_locks/acquirer/extend_lock_ttl.rb +125 -13
- data/lib/redis_queued_locks/acquirer/is_locked.rb +0 -1
- data/lib/redis_queued_locks/acquirer/is_queued.rb +0 -1
- data/lib/redis_queued_locks/acquirer/keys.rb +16 -3
- data/lib/redis_queued_locks/acquirer/lock_info.rb +31 -39
- data/lib/redis_queued_locks/acquirer/lock_series_poc/instr_visitor.rb +11 -5
- data/lib/redis_queued_locks/acquirer/lock_series_poc/log_visitor.rb +20 -10
- data/lib/redis_queued_locks/acquirer/lock_series_poc.rb +105 -36
- data/lib/redis_queued_locks/acquirer/locks.rb +32 -11
- data/lib/redis_queued_locks/acquirer/queue_info.rb +30 -8
- data/lib/redis_queued_locks/acquirer/queues.rb +26 -6
- data/lib/redis_queued_locks/acquirer/reindex_locks.rb +117 -4
- data/lib/redis_queued_locks/acquirer/release_all_locks.rb +37 -6
- data/lib/redis_queued_locks/acquirer/release_lock.rb +33 -7
- data/lib/redis_queued_locks/acquirer/release_locks_of.rb +45 -6
- data/lib/redis_queued_locks/acquirer/release_read_lock.rb +22 -3
- data/lib/redis_queued_locks/client.rb +140 -56
- data/lib/redis_queued_locks/config.rb +105 -14
- data/lib/redis_queued_locks/errors.rb +34 -4
- data/lib/redis_queued_locks/instrument/sampler.rb +4 -7
- data/lib/redis_queued_locks/logging/sampler.rb +4 -8
- data/lib/redis_queued_locks/resource.rb +137 -12
- data/lib/redis_queued_locks/swarm/flush_zombies.rb +1 -0
- data/lib/redis_queued_locks/swarm/redis_client_builder.rb +8 -4
- data/lib/redis_queued_locks/swarm/swarm_element/threaded.rb +8 -6
- data/lib/redis_queued_locks/swarm/zombie_info.rb +6 -2
- data/lib/redis_queued_locks/swarm.rb +86 -5
- data/lib/redis_queued_locks/utilities.rb +1 -1
- data/lib/redis_queued_locks/version.rb +2 -2
- data/rbs_collection.lock.yaml +4 -0
- data/rbs_collection.yaml +2 -1
- data/sig/manifest.yml +1 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs +2 -2
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +2 -2
- data/sig/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rbs +25 -5
- data/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs +32 -12
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs +61 -40
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +59 -11
- data/sig/redis_queued_locks/acquirer/acquire_lock/{yield_with_expire → yield_expire}/log_visitor.rbs +4 -4
- data/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs +4 -4
- data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +6 -4
- data/sig/redis_queued_locks/acquirer/clear_dead_requests.rbs +23 -1
- data/sig/redis_queued_locks/acquirer/extend_lock_ttl.rbs +16 -3
- data/sig/redis_queued_locks/acquirer/queues.rbs +1 -1
- data/sig/redis_queued_locks/acquirer/reindex_locks.rbs +22 -1
- data/sig/redis_queued_locks/acquirer/release_lock.rbs +3 -2
- data/sig/redis_queued_locks/acquirer/release_read_lock.rbs +1 -1
- data/sig/redis_queued_locks/client.rbs +24 -10
- data/sig/redis_queued_locks/config.rbs +54 -1
- data/sig/redis_queued_locks/errors.rbs +5 -2
- data/sig/redis_queued_locks/instrument/sampler.rbs +3 -3
- data/sig/redis_queued_locks/instrument/void_notifier.rbs +3 -1
- data/sig/redis_queued_locks/logging/sampler.rbs +3 -3
- data/sig/redis_queued_locks/resource.rbs +23 -13
- data/sig/redis_queued_locks/swarm/swarm_element/threaded.rbs +1 -1
- data/sig/redis_queued_locks/utilities.rbs +2 -1
- data/sig/redis_queued_locks.rbs +7 -0
- data/sig/vendor/redis_client.rbs +1 -0
- metadata +4 -3
- /data/sig/redis_queued_locks/{acquier.rbs → acquirer.rbs} +0 -0
|
@@ -13,6 +13,7 @@ module RedisQueuedLocks
|
|
|
13
13
|
LOCK_STATE_QUEUE_REPLIES_AT: Integer
|
|
14
14
|
QUEUE_HEAD_REPLY: Integer
|
|
15
15
|
OPPOSITE_QUEUE_HEAD_REPLY: Integer
|
|
16
|
+
MAX_DEAD_REQUEST_REMOVALS: Integer
|
|
16
17
|
|
|
17
18
|
# { ok: bool, result: Symbol }
|
|
18
19
|
# { ok: bool, result: Symbol }
|
|
@@ -25,7 +26,7 @@ module RedisQueuedLocks
|
|
|
25
26
|
# hst_id: String,
|
|
26
27
|
# ts: Integer?,
|
|
27
28
|
# ttl: Integer?,
|
|
28
|
-
# rw_mode:
|
|
29
|
+
# rw_mode: RQL::readWriteMode
|
|
29
30
|
# }
|
|
30
31
|
# }
|
|
31
32
|
|
|
@@ -34,7 +35,7 @@ module RedisQueuedLocks
|
|
|
34
35
|
RQL::loggerObj logger,
|
|
35
36
|
bool log_lock_try,
|
|
36
37
|
String lock_key,
|
|
37
|
-
|
|
38
|
+
RQL::readWriteMode read_write_mode,
|
|
38
39
|
String lock_key_queue,
|
|
39
40
|
String read_lock_key_queue,
|
|
40
41
|
String lock_readers_key,
|
|
@@ -43,13 +44,14 @@ module RedisQueuedLocks
|
|
|
43
44
|
String acquirer_id,
|
|
44
45
|
String host_id,
|
|
45
46
|
Integer|Float acquirer_position,
|
|
47
|
+
Integer priority,
|
|
46
48
|
Integer? ttl,
|
|
47
49
|
Integer queue_ttl,
|
|
48
50
|
bool lock_index_enabled,
|
|
49
51
|
Integer lock_index_grace_period,
|
|
50
52
|
bool fail_fast,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
RQL::conflictStrategy conflict_strategy,
|
|
54
|
+
RQL::accessStrategy access_strategy,
|
|
53
55
|
Hash[String|Symbol,untyped]? meta,
|
|
54
56
|
bool retry_attempt,
|
|
55
57
|
bool log_sampled,
|
|
@@ -63,6 +65,7 @@ module RedisQueuedLocks
|
|
|
63
65
|
String request_queue,
|
|
64
66
|
String opposite_request_queue,
|
|
65
67
|
Integer|Float acquirer_position,
|
|
68
|
+
Integer priority,
|
|
66
69
|
String acquirer_id,
|
|
67
70
|
Float acquirer_dead_score,
|
|
68
71
|
String lock_name,
|
|
@@ -71,6 +74,14 @@ module RedisQueuedLocks
|
|
|
71
74
|
Integer lock_index_grace_period
|
|
72
75
|
) -> void
|
|
73
76
|
|
|
77
|
+
def pipeline_dead_requests_removal: (
|
|
78
|
+
RedisClient::Pipeline pipeline,
|
|
79
|
+
String request_queue,
|
|
80
|
+
String opposite_request_queue,
|
|
81
|
+
Float acquirer_dead_score,
|
|
82
|
+
Integer priority
|
|
83
|
+
) -> void
|
|
84
|
+
|
|
74
85
|
def pipeline_lock_state: (
|
|
75
86
|
RedisClient::Pipeline pipeline,
|
|
76
87
|
String lock_key,
|
|
@@ -81,6 +92,7 @@ module RedisQueuedLocks
|
|
|
81
92
|
String request_queue,
|
|
82
93
|
String opposite_request_queue,
|
|
83
94
|
Integer|Float acquirer_position,
|
|
95
|
+
Integer priority,
|
|
84
96
|
Float acquirer_dead_score,
|
|
85
97
|
String lock_name,
|
|
86
98
|
Integer queue_ttl,
|
|
@@ -89,7 +101,7 @@ module RedisQueuedLocks
|
|
|
89
101
|
) -> void
|
|
90
102
|
|
|
91
103
|
def find_opposite_request_ahead: (
|
|
92
|
-
|
|
104
|
+
RQL::accessStrategy access_strategy,
|
|
93
105
|
[String, Float]? opposite_waiting_request,
|
|
94
106
|
Integer|Float acquirer_position,
|
|
95
107
|
String acquirer_id
|
|
@@ -104,7 +116,7 @@ module RedisQueuedLocks
|
|
|
104
116
|
|
|
105
117
|
def lock_obstacle: (
|
|
106
118
|
bool read_mode,
|
|
107
|
-
|
|
119
|
+
RQL::accessStrategy access_strategy,
|
|
108
120
|
String acquirer_id,
|
|
109
121
|
String? waiting_acquirer,
|
|
110
122
|
String? opposite_request_ahead,
|
|
@@ -122,20 +134,55 @@ module RedisQueuedLocks
|
|
|
122
134
|
Integer queue_ttl,
|
|
123
135
|
String acquirer_id,
|
|
124
136
|
String host_id,
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
RQL::accessStrategy access_strategy,
|
|
138
|
+
RQL::readWriteMode read_write_mode,
|
|
127
139
|
String? waiting_acquirer,
|
|
128
|
-
|
|
140
|
+
Integer? waiting_priority,
|
|
141
|
+
[String, Float]? opposite_waiting_request,
|
|
129
142
|
String? current_lock_obtainer
|
|
130
143
|
) -> void
|
|
131
144
|
|
|
145
|
+
def logged_request_priority: (
|
|
146
|
+
bool log_sampled,
|
|
147
|
+
bool log_lock_try,
|
|
148
|
+
[String, Float]? lock_request
|
|
149
|
+
) -> Integer?
|
|
150
|
+
|
|
151
|
+
def drop_dead_requests_ahead: (
|
|
152
|
+
RC::client rconn,
|
|
153
|
+
RQL::readWriteMode read_write_mode,
|
|
154
|
+
String request_queue,
|
|
155
|
+
String opposite_request_queue,
|
|
156
|
+
String acquirer_id,
|
|
157
|
+
Integer|Float acquirer_position,
|
|
158
|
+
Float acquirer_dead_score,
|
|
159
|
+
RQL::accessStrategy access_strategy,
|
|
160
|
+
[String, Float]? waiting_request,
|
|
161
|
+
[String, Float]? opposite_waiting_request
|
|
162
|
+
) -> [[String, Float]?, [String, Float]?, Array[[String, Integer]]]?
|
|
163
|
+
|
|
164
|
+
def log_dropped_requests: (
|
|
165
|
+
RQL::loggerObj logger,
|
|
166
|
+
bool log_sampled,
|
|
167
|
+
bool log_lock_try,
|
|
168
|
+
String lock_key,
|
|
169
|
+
Integer queue_ttl,
|
|
170
|
+
String acquirer_id,
|
|
171
|
+
String host_id,
|
|
172
|
+
RQL::accessStrategy access_strategy,
|
|
173
|
+
RQL::readWriteMode read_write_mode,
|
|
174
|
+
Array[[String, Integer]] dropped_requests
|
|
175
|
+
) -> void
|
|
176
|
+
|
|
177
|
+
def dead_request_priority: ([String, Float] lock_request, Float acquirer_dead_score) -> Integer?
|
|
178
|
+
|
|
132
179
|
def precheck_lock: (
|
|
133
180
|
RC::client rconn,
|
|
134
181
|
RQL::loggerObj logger,
|
|
135
182
|
bool log_sampled,
|
|
136
183
|
bool log_lock_try,
|
|
137
184
|
String lock_key,
|
|
138
|
-
|
|
185
|
+
RQL::readWriteMode read_write_mode,
|
|
139
186
|
String lock_readers_key,
|
|
140
187
|
String request_queue,
|
|
141
188
|
String opposite_request_queue,
|
|
@@ -143,12 +190,13 @@ module RedisQueuedLocks
|
|
|
143
190
|
String acquirer_id,
|
|
144
191
|
String host_id,
|
|
145
192
|
Integer|Float acquirer_position,
|
|
193
|
+
Integer priority,
|
|
146
194
|
Float acquirer_dead_score,
|
|
147
195
|
Integer queue_ttl,
|
|
148
196
|
bool lock_index_enabled,
|
|
149
197
|
Integer lock_index_grace_period,
|
|
150
198
|
bool fail_fast,
|
|
151
|
-
|
|
199
|
+
RQL::accessStrategy access_strategy
|
|
152
200
|
) -> (lockObstacle | :fail_fast_no_try)?
|
|
153
201
|
end
|
|
154
202
|
end
|
data/sig/redis_queued_locks/acquirer/acquire_lock/{yield_with_expire → yield_expire}/log_visitor.rbs
RENAMED
|
@@ -12,8 +12,8 @@ module RedisQueuedLocks
|
|
|
12
12
|
Integer queue_ttl,
|
|
13
13
|
String acquirer_id,
|
|
14
14
|
String host_id,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
RQL::accessStrategy access_strategy,
|
|
16
|
+
RQL::readWriteMode rw_mode
|
|
17
17
|
) -> void
|
|
18
18
|
|
|
19
19
|
def self.decrease_lock: (
|
|
@@ -24,8 +24,8 @@ module RedisQueuedLocks
|
|
|
24
24
|
Integer queue_ttl,
|
|
25
25
|
String acquirer_id,
|
|
26
26
|
String host_id,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
RQL::accessStrategy access_strategy,
|
|
28
|
+
RQL::readWriteMode rw_mode
|
|
29
29
|
) -> void
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -13,13 +13,13 @@ module RedisQueuedLocks
|
|
|
13
13
|
String lock_key,
|
|
14
14
|
String lock_readers_key,
|
|
15
15
|
String? read_lock_key,
|
|
16
|
-
|
|
16
|
+
RQL::readWriteMode rw_mode,
|
|
17
17
|
String acquirer_id,
|
|
18
18
|
String host_id,
|
|
19
|
-
|
|
19
|
+
RQL::accessStrategy access_strategy,
|
|
20
20
|
bool timed,
|
|
21
21
|
Integer|Float ttl_shift,
|
|
22
|
-
Integer
|
|
22
|
+
Integer ttl,
|
|
23
23
|
Integer queue_ttl,
|
|
24
24
|
Hash[String|Symbol,untyped]? meta,
|
|
25
25
|
bool log_sampled,
|
|
@@ -33,7 +33,7 @@ module RedisQueuedLocks
|
|
|
33
33
|
def yield_with_timeout: (
|
|
34
34
|
Float timeout,
|
|
35
35
|
String lock_key,
|
|
36
|
-
Integer
|
|
36
|
+
Integer lock_ttl,
|
|
37
37
|
String acquirer_id,
|
|
38
38
|
String host_id,
|
|
39
39
|
Hash[String|Symbol,untyped]? meta,
|
|
@@ -19,7 +19,7 @@ module RedisQueuedLocks
|
|
|
19
19
|
thread_id: Integer|String,
|
|
20
20
|
fiber_id: Integer|String,
|
|
21
21
|
ractor_id: Integer|String,
|
|
22
|
-
ttl: Integer
|
|
22
|
+
ttl: Integer,
|
|
23
23
|
queue_ttl: Integer,
|
|
24
24
|
lock_index_enabled: bool,
|
|
25
25
|
lock_index_grace_period: Integer,
|
|
@@ -37,9 +37,11 @@ module RedisQueuedLocks
|
|
|
37
37
|
logger: RQL::loggerObj,
|
|
38
38
|
log_lock_try: bool,
|
|
39
39
|
instrument: untyped?,
|
|
40
|
-
conflict_strategy:
|
|
41
|
-
read_write_mode: Symbol,
|
|
42
|
-
access_strategy:
|
|
40
|
+
conflict_strategy: RQL::conflictStrategy,
|
|
41
|
+
read_write_mode: Symbol, # NOTE: (rbs test) validated at runtime (Step 0.1 (RW)): any Symbol is accepted here
|
|
42
|
+
access_strategy: RQL::accessStrategy,
|
|
43
|
+
priority: RQL::lockPriority,
|
|
44
|
+
lock_priorities: Hash[Symbol, Integer],
|
|
43
45
|
log_sampling_enabled: bool,
|
|
44
46
|
log_sampling_percent: Integer,
|
|
45
47
|
log_sampler: RQL::Logging::samplerObj,
|
|
@@ -4,11 +4,14 @@ use RedisClient as RC
|
|
|
4
4
|
module RedisQueuedLocks
|
|
5
5
|
module Acquirer
|
|
6
6
|
module ClearDeadRequests
|
|
7
|
+
extend RQL::Utilities
|
|
8
|
+
|
|
7
9
|
type clearResult = { ok: bool, result: { processed_queues: Set[String] } }
|
|
8
10
|
def self.clear_dead_requests: (
|
|
9
11
|
RC::client redis_client,
|
|
10
12
|
Integer scan_size,
|
|
11
13
|
Integer dead_ttl,
|
|
14
|
+
bool by_priority,
|
|
12
15
|
bool lock_index_enabled,
|
|
13
16
|
RQL::loggerObj logger,
|
|
14
17
|
RQL::instrObj instrumenter,
|
|
@@ -23,12 +26,31 @@ module RedisQueuedLocks
|
|
|
23
26
|
bool instr_sample_this
|
|
24
27
|
) -> clearResult
|
|
25
28
|
|
|
29
|
+
private def self.fully_clear_dead_requests: (
|
|
30
|
+
RC::client redis_client,
|
|
31
|
+
Integer scan_size,
|
|
32
|
+
Integer dead_ttl,
|
|
33
|
+
bool by_priority,
|
|
34
|
+
bool lock_index_enabled
|
|
35
|
+
) -> Set[String]
|
|
36
|
+
|
|
26
37
|
private def self.each_lock_queue: (RC::client redis_client, Integer scan_size) { (String lock_queue) -> void } -> void
|
|
27
|
-
private def self.drop_dead_requests: (
|
|
38
|
+
private def self.drop_dead_requests: (
|
|
39
|
+
RC::client redis_client,
|
|
40
|
+
Array[String] lock_queues,
|
|
41
|
+
Float dead_score,
|
|
42
|
+
bool by_priority
|
|
43
|
+
) -> Array[Array[[String, Float]]]
|
|
44
|
+
private def self.drop_dead_requests_by_priority: (
|
|
45
|
+
RC::client redis_client,
|
|
46
|
+
Array[String] lock_queues,
|
|
47
|
+
Float dead_score
|
|
48
|
+
) -> Array[Array[[String, Float]]]
|
|
28
49
|
private def self.drop_dead_requests_of_locks: (
|
|
29
50
|
RC::client redis_client,
|
|
30
51
|
Array[String] lock_names,
|
|
31
52
|
Float dead_score,
|
|
53
|
+
bool by_priority,
|
|
32
54
|
Set[String] processed_queues
|
|
33
55
|
) -> void
|
|
34
56
|
private def self.each_lock_name_batch: (RC::client redis_client, Integer scan_size) { (Array[String] lock_names) -> void } -> void
|
|
@@ -4,6 +4,8 @@ use RedisClient as RC
|
|
|
4
4
|
module RedisQueuedLocks
|
|
5
5
|
module Acquirer
|
|
6
6
|
module ExtendLockTTL
|
|
7
|
+
extend RQL::Utilities
|
|
8
|
+
|
|
7
9
|
EXTEND_LOCK_PTTL: String
|
|
8
10
|
|
|
9
11
|
type extendResult = { ok: bool, result: { extended_locks_count: Integer } | Symbol }
|
|
@@ -11,23 +13,34 @@ module RedisQueuedLocks
|
|
|
11
13
|
RC::client redis_client,
|
|
12
14
|
String lock_name,
|
|
13
15
|
Integer milliseconds,
|
|
14
|
-
Symbol read_write_mode,
|
|
16
|
+
Symbol read_write_mode, # NOTE: (rbs test) validated at runtime: any Symbol is accepted here
|
|
15
17
|
bool all_read_locks,
|
|
16
18
|
String acquirer_id,
|
|
17
19
|
bool lock_index_enabled,
|
|
18
20
|
RQL::loggerObj logger,
|
|
19
21
|
RQL::instrObj instrumenter,
|
|
20
22
|
untyped? instrument,
|
|
21
|
-
bool
|
|
23
|
+
bool log_sampling_enabled,
|
|
22
24
|
Integer log_sampling_percent,
|
|
23
25
|
RQL::Logging::samplerObj log_sampler,
|
|
24
|
-
bool
|
|
26
|
+
bool log_sample_this,
|
|
25
27
|
bool instr_sampling_enabled,
|
|
26
28
|
Integer instr_sampling_percent,
|
|
27
29
|
RQL::Instrument::samplerObj instr_sampler,
|
|
28
30
|
bool instr_sample_this
|
|
29
31
|
) -> extendResult
|
|
30
32
|
|
|
33
|
+
private def self.fully_extend_lock_ttl: (
|
|
34
|
+
RC::client redis_client,
|
|
35
|
+
String lock_name,
|
|
36
|
+
String lock_key,
|
|
37
|
+
Integer milliseconds,
|
|
38
|
+
RQL::readWriteMode read_write_mode,
|
|
39
|
+
bool all_read_locks,
|
|
40
|
+
String acquirer_id,
|
|
41
|
+
bool lock_index_enabled
|
|
42
|
+
) -> extendResult
|
|
43
|
+
|
|
31
44
|
private def self.extend_read_lock_ttl: (
|
|
32
45
|
RC::client redis_client,
|
|
33
46
|
String lock_name,
|
|
@@ -4,7 +4,7 @@ module RedisQueuedLocks
|
|
|
4
4
|
module Acquirer
|
|
5
5
|
module Queues
|
|
6
6
|
type queueList = Set[String]
|
|
7
|
-
type queuesInfo = Set[{ queue: String, requests: Array[Hash[String,String|Float]] }]
|
|
7
|
+
type queuesInfo = Set[{ queue: String, requests: Array[Hash[String,String|Integer|Float]] }]
|
|
8
8
|
type queues = queueList | queuesInfo
|
|
9
9
|
|
|
10
10
|
def self.queues: (
|
|
@@ -1,16 +1,37 @@
|
|
|
1
|
+
use RedisQueuedLocks as RQL
|
|
1
2
|
use RedisClient as RC
|
|
2
3
|
|
|
3
4
|
module RedisQueuedLocks
|
|
4
5
|
module Acquirer
|
|
5
6
|
module ReindexLocks
|
|
7
|
+
extend RQL::Utilities
|
|
8
|
+
|
|
6
9
|
type reindexResult = { ok: bool, result: { idx_key_cnt: Integer } }
|
|
7
10
|
def self.reindex_locks: (
|
|
8
11
|
RC::client redis_client,
|
|
9
12
|
Integer scan_size,
|
|
10
13
|
Integer queue_ttl,
|
|
11
|
-
Integer lock_index_grace_period
|
|
14
|
+
Integer lock_index_grace_period,
|
|
15
|
+
RQL::loggerObj logger,
|
|
16
|
+
RQL::instrObj instrumenter,
|
|
17
|
+
untyped? instrument,
|
|
18
|
+
bool log_sampling_enabled,
|
|
19
|
+
Integer log_sampling_percent,
|
|
20
|
+
RQL::Logging::samplerObj log_sampler,
|
|
21
|
+
bool log_sample_this,
|
|
22
|
+
bool instr_sampling_enabled,
|
|
23
|
+
Integer instr_sampling_percent,
|
|
24
|
+
RQL::Instrument::samplerObj instr_sampler,
|
|
25
|
+
bool instr_sample_this
|
|
12
26
|
) -> reindexResult
|
|
13
27
|
|
|
28
|
+
private def self.fully_reindex_locks: (
|
|
29
|
+
RC::client redis_client,
|
|
30
|
+
Integer scan_size,
|
|
31
|
+
Integer queue_ttl,
|
|
32
|
+
Integer lock_index_grace_period
|
|
33
|
+
) -> Integer
|
|
34
|
+
|
|
14
35
|
private def self.index_lock_keys: (
|
|
15
36
|
RC::client redis_client,
|
|
16
37
|
Array[String] lock_keys,
|
|
@@ -20,10 +20,11 @@ module RedisQueuedLocks
|
|
|
20
20
|
RC::client redis,
|
|
21
21
|
String lock_name,
|
|
22
22
|
bool lock_index_enabled,
|
|
23
|
-
RQL::instrObj instrumenter,
|
|
24
23
|
RQL::loggerObj logger,
|
|
24
|
+
RQL::instrObj instrumenter,
|
|
25
|
+
untyped? instrument,
|
|
25
26
|
bool log_sampling_enabled,
|
|
26
|
-
Integer
|
|
27
|
+
Integer log_sampling_percent,
|
|
27
28
|
RQL::Logging::samplerObj log_sampler,
|
|
28
29
|
bool log_sample_this,
|
|
29
30
|
bool instr_sampling_enabled,
|
|
@@ -19,8 +19,8 @@ module RedisQueuedLocks
|
|
|
19
19
|
RC::client redis,
|
|
20
20
|
String lock_name,
|
|
21
21
|
String acquirer_id,
|
|
22
|
-
RQL::instrObj instrumenter,
|
|
23
22
|
RQL::loggerObj logger,
|
|
23
|
+
RQL::instrObj instrumenter,
|
|
24
24
|
untyped? instrument,
|
|
25
25
|
bool log_sampling_enabled,
|
|
26
26
|
Integer log_sampling_percent,
|
|
@@ -44,9 +44,10 @@ module RedisQueuedLocks
|
|
|
44
44
|
?retry_jitter: Integer,
|
|
45
45
|
?raise_errors: bool,
|
|
46
46
|
?fail_fast: bool,
|
|
47
|
-
?conflict_strategy:
|
|
48
|
-
?read_write_mode:
|
|
49
|
-
?access_strategy:
|
|
47
|
+
?conflict_strategy: RQL::conflictStrategy,
|
|
48
|
+
?read_write_mode: RQL::readWriteMode,
|
|
49
|
+
?access_strategy: RQL::accessStrategy,
|
|
50
|
+
?priority: RQL::lockPriority,
|
|
50
51
|
?identity: String,
|
|
51
52
|
?meta: Hash[String|Symbol,untyped]?,
|
|
52
53
|
?detailed_acq_timeout_error: bool,
|
|
@@ -75,9 +76,10 @@ module RedisQueuedLocks
|
|
|
75
76
|
?retry_delay: Integer,
|
|
76
77
|
?retry_jitter: Integer,
|
|
77
78
|
?fail_fast: bool,
|
|
78
|
-
?conflict_strategy:
|
|
79
|
-
?read_write_mode:
|
|
80
|
-
?access_strategy:
|
|
79
|
+
?conflict_strategy: RQL::conflictStrategy,
|
|
80
|
+
?read_write_mode: RQL::readWriteMode,
|
|
81
|
+
?access_strategy: RQL::accessStrategy,
|
|
82
|
+
?priority: RQL::lockPriority,
|
|
81
83
|
?identity: String,
|
|
82
84
|
?instrumenter: RQL::instrObj,
|
|
83
85
|
?meta: Hash[String|Symbol,untyped]?,
|
|
@@ -141,7 +143,7 @@ module RedisQueuedLocks
|
|
|
141
143
|
?ractor_id: Integer|String,
|
|
142
144
|
?identity: String
|
|
143
145
|
) -> String
|
|
144
|
-
alias
|
|
146
|
+
alias current_acq_id current_acquirer_id
|
|
145
147
|
alias acq_id current_acquirer_id
|
|
146
148
|
|
|
147
149
|
def current_host_id: (
|
|
@@ -158,7 +160,7 @@ module RedisQueuedLocks
|
|
|
158
160
|
def extend_lock_ttl: (
|
|
159
161
|
String lock_name,
|
|
160
162
|
Integer milliseconds,
|
|
161
|
-
?read_write_mode:
|
|
163
|
+
?read_write_mode: RQL::readWriteMode,
|
|
162
164
|
?all_read_locks: bool,
|
|
163
165
|
?identity: String,
|
|
164
166
|
?logger: RQL::loggerObj,
|
|
@@ -236,12 +238,13 @@ module RedisQueuedLocks
|
|
|
236
238
|
| (?scan_size: Integer, ?with_info: true) -> RQL::Acquirer::Queues::queuesInfo
|
|
237
239
|
| (?scan_size: Integer, ?with_info: false) -> RQL::Acquirer::Queues::queueList
|
|
238
240
|
|
|
239
|
-
def queues_info: (?scan_size: Integer) -> RQL::Acquirer::Queues::
|
|
241
|
+
def queues_info: (?scan_size: Integer) -> RQL::Acquirer::Queues::queuesInfo
|
|
240
242
|
def keys: (?scan_size: Integer) -> RQL::Acquirer::Keys::keyList
|
|
241
243
|
|
|
242
244
|
def clear_dead_requests: (
|
|
243
245
|
?dead_ttl: Integer,
|
|
244
246
|
?scan_size: Integer,
|
|
247
|
+
?by_priority: bool,
|
|
245
248
|
?logger: RQL::loggerObj,
|
|
246
249
|
?instrumenter: RQL::instrObj,
|
|
247
250
|
?instrument: untyped?,
|
|
@@ -258,7 +261,18 @@ module RedisQueuedLocks
|
|
|
258
261
|
def reindex_locks: (
|
|
259
262
|
?scan_size: Integer,
|
|
260
263
|
?queue_ttl: Integer,
|
|
261
|
-
?lock_index_grace_period: Integer
|
|
264
|
+
?lock_index_grace_period: Integer,
|
|
265
|
+
?logger: RQL::loggerObj,
|
|
266
|
+
?instrumenter: RQL::instrObj,
|
|
267
|
+
?instrument: untyped?,
|
|
268
|
+
?log_sampling_enabled: bool,
|
|
269
|
+
?log_sampling_percent: Integer,
|
|
270
|
+
?log_sampler: RQL::Logging::samplerObj,
|
|
271
|
+
?log_sample_this: bool,
|
|
272
|
+
?instr_sampling_enabled: bool,
|
|
273
|
+
?instr_sampling_percent: Integer,
|
|
274
|
+
?instr_sampler: RQL::Instrument::samplerObj,
|
|
275
|
+
?instr_sample_this: bool
|
|
262
276
|
) -> RQL::Acquirer::ReindexLocks::reindexResult
|
|
263
277
|
end
|
|
264
278
|
end
|
|
@@ -7,11 +7,60 @@ module RedisQueuedLocks
|
|
|
7
7
|
type configState = Hash[String,untyped]
|
|
8
8
|
|
|
9
9
|
@config_state: configState
|
|
10
|
+
@configuring: bool
|
|
10
11
|
attr_reader config_state: configState
|
|
11
12
|
|
|
12
13
|
def initialize: () ?{ (RedisQueuedLocks::Config) -> void } -> void
|
|
13
14
|
def configure: () ?{ (RedisQueuedLocks::Config) -> void } -> void
|
|
14
|
-
|
|
15
|
+
# NOTE: (typed config lookups) one overload per config key (the `setting` list of `config.rb`):
|
|
16
|
+
# Steep checks `config['...']` defaults in `Client` and rejects unknown keys;
|
|
17
|
+
# keep this table in sync with `setting`/`validate`;
|
|
18
|
+
def []: ("retry_count") -> Integer?
|
|
19
|
+
| ("retry_delay") -> Integer
|
|
20
|
+
| ("retry_jitter") -> Integer
|
|
21
|
+
| ("try_to_lock_timeout") -> Integer?
|
|
22
|
+
| ("default_lock_ttl") -> Integer
|
|
23
|
+
| ("default_queue_ttl") -> Integer
|
|
24
|
+
| ("detailed_acq_timeout_error") -> bool
|
|
25
|
+
| ("lock_release_batch_size") -> Integer
|
|
26
|
+
| ("clear_locks_of__lock_scan_size") -> Integer
|
|
27
|
+
| ("clear_locks_of__queue_scan_size") -> Integer
|
|
28
|
+
| ("key_extraction_batch_size") -> Integer
|
|
29
|
+
| ("instrumenter") -> RedisQueuedLocks::instrObj
|
|
30
|
+
| ("uniq_identifier") -> ^() -> String
|
|
31
|
+
| ("logger") -> RedisQueuedLocks::loggerObj
|
|
32
|
+
| ("log_lock_try") -> bool
|
|
33
|
+
| ("dead_request_ttl") -> Integer
|
|
34
|
+
| ("lock_index_enabled") -> bool
|
|
35
|
+
| ("lock_index_grace_period") -> Integer
|
|
36
|
+
| ("is_timed_by_default") -> bool
|
|
37
|
+
| ("default_conflict_strategy") -> RedisQueuedLocks::conflictStrategy
|
|
38
|
+
| ("default_access_strategy") -> RedisQueuedLocks::accessStrategy
|
|
39
|
+
| ("lock_priorities") -> Hash[Symbol, Integer]
|
|
40
|
+
| ("default_lock_priority") -> RedisQueuedLocks::lockPriority
|
|
41
|
+
| ("log_sampling_enabled") -> bool
|
|
42
|
+
| ("log_sampling_percent") -> Integer
|
|
43
|
+
| ("log_sampler") -> RedisQueuedLocks::Logging::samplerObj
|
|
44
|
+
| ("instr_sampling_enabled") -> bool
|
|
45
|
+
| ("instr_sampling_percent") -> Integer
|
|
46
|
+
| ("instr_sampler") -> RedisQueuedLocks::Instrument::samplerObj
|
|
47
|
+
| ("swarm.auto_swarm") -> bool
|
|
48
|
+
| ("swarm.supervisor.liveness_probing_period") -> Integer
|
|
49
|
+
| ("swarm.probe_hosts.enabled_for_swarm") -> bool
|
|
50
|
+
| ("swarm.probe_hosts.probe_period") -> Integer
|
|
51
|
+
| ("swarm.probe_hosts.redis_config.sentinel") -> bool
|
|
52
|
+
| ("swarm.probe_hosts.redis_config.pooled") -> bool
|
|
53
|
+
| ("swarm.probe_hosts.redis_config.config") -> Hash[untyped,untyped]
|
|
54
|
+
| ("swarm.probe_hosts.redis_config.pool_config") -> Hash[untyped,untyped]
|
|
55
|
+
| ("swarm.flush_zombies.enabled_for_swarm") -> bool
|
|
56
|
+
| ("swarm.flush_zombies.zombie_ttl") -> Integer
|
|
57
|
+
| ("swarm.flush_zombies.zombie_lock_scan_size") -> Integer
|
|
58
|
+
| ("swarm.flush_zombies.zombie_queue_scan_size") -> Integer
|
|
59
|
+
| ("swarm.flush_zombies.zombie_flush_period") -> Integer
|
|
60
|
+
| ("swarm.flush_zombies.redis_config.sentinel") -> bool
|
|
61
|
+
| ("swarm.flush_zombies.redis_config.pooled") -> bool
|
|
62
|
+
| ("swarm.flush_zombies.redis_config.config") -> Hash[untyped,untyped]
|
|
63
|
+
| ("swarm.flush_zombies.redis_config.pool_config") -> Hash[untyped,untyped]
|
|
15
64
|
def []=: (String config_key, untyped config_value) -> void
|
|
16
65
|
def slice: (String config_key_pattern) -> configState
|
|
17
66
|
|
|
@@ -19,5 +68,9 @@ module RedisQueuedLocks
|
|
|
19
68
|
|
|
20
69
|
def prevent_key__non_existent: (String config_key) -> void
|
|
21
70
|
def prevent_key__invalid_type: (String config_key, untyped config_value) -> void
|
|
71
|
+
def prevent_default_priority__unknown_name: (
|
|
72
|
+
Hash[Symbol, Integer] lock_priorities,
|
|
73
|
+
RedisQueuedLocks::lockPriority default_lock_priority
|
|
74
|
+
) -> void
|
|
22
75
|
end
|
|
23
76
|
end
|
|
@@ -5,10 +5,13 @@ module RedisQueuedLocks
|
|
|
5
5
|
class ArgumentError < ::ArgumentError
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
+
class Exception < ::Exception
|
|
9
|
+
end
|
|
10
|
+
|
|
8
11
|
class LockAlreadyObtainedError < Error
|
|
9
12
|
end
|
|
10
13
|
|
|
11
|
-
class LockAcquirementIntermediateTimeoutError <
|
|
14
|
+
class LockAcquirementIntermediateTimeoutError < Exception
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
class LockAcquirementTimeoutError < Error
|
|
@@ -17,7 +20,7 @@ module RedisQueuedLocks
|
|
|
17
20
|
class LockAcquirementRetryLimitError < Error
|
|
18
21
|
end
|
|
19
22
|
|
|
20
|
-
class TimedLockIntermediateTimeoutError <
|
|
23
|
+
class TimedLockIntermediateTimeoutError < Exception
|
|
21
24
|
end
|
|
22
25
|
|
|
23
26
|
class TimedLockTimeoutError < Error
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module RedisQueuedLocks
|
|
2
2
|
module Instrument
|
|
3
3
|
module Sampler
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def self.sampling_happened?: (Integer sampling_percent) -> bool
|
|
4
|
+
# NOTE: (rbs test) not hooked: `valid_sampler?` introspects `#parameters` of this method,
|
|
5
|
+
# and a hooked method has the `(*rest, &block)` parameters;
|
|
6
|
+
%a{rbs:test:skip} def self.sampling_happened?: (Integer sampling_percent) -> bool
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
module RedisQueuedLocks
|
|
2
2
|
module Instrument
|
|
3
3
|
module VoidNotifier
|
|
4
|
-
|
|
4
|
+
# NOTE: (rbs test) not hooked: `Instrument.valid_interface?` introspects `#parameters` of `notify`,
|
|
5
|
+
# and a hooked method has the `(*rest, &block)` parameters;
|
|
6
|
+
%a{rbs:test:skip} def self.notify: (String event, ?Hash[untyped,untyped] payload) -> void
|
|
5
7
|
end
|
|
6
8
|
end
|
|
7
9
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module RedisQueuedLocks
|
|
2
2
|
module Logging
|
|
3
3
|
module Sampler
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def self.sampling_happened?: (Integer sampling_percent) -> bool
|
|
4
|
+
# NOTE: (rbs test) not hooked: `valid_sampler?` introspects `#parameters` of this method,
|
|
5
|
+
# and a hooked method has the `(*rest, &block)` parameters;
|
|
6
|
+
%a{rbs:test:skip} def self.sampling_happened?: (Integer sampling_percent) -> bool
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
end
|