redis_queued_locks 1.21.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 +294 -51
- data/.claude/rules/acquirer.md +16 -11
- 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 +14 -15
- data/.claude/rules/swarm.md +3 -4
- data/.claude/rules/tests.md +9 -9
- data/.claude/rules/type-checking.md +14 -16
- data/.claude/rules/visitors.md +11 -9
- data/.claude/skills/rql-code-review/SKILL.md +129 -47
- data/.ruby-version +1 -1
- data/CHANGELOG.md +122 -245
- data/CLAUDE.md +12 -10
- data/README.md +516 -175
- data/Rakefile +11 -0
- data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb +4 -4
- data/lib/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rb +28 -12
- data/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb +38 -16
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb +92 -15
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb +945 -272
- data/lib/redis_queued_locks/acquirer/acquire_lock.rb +82 -32
- data/lib/redis_queued_locks/acquirer/clear_dead_requests.rb +240 -45
- data/lib/redis_queued_locks/acquirer/extend_lock_ttl.rb +15 -13
- data/lib/redis_queued_locks/acquirer/keys.rb +6 -2
- 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/locks.rb +6 -2
- data/lib/redis_queued_locks/acquirer/queue_info.rb +30 -7
- data/lib/redis_queued_locks/acquirer/queues.rb +17 -6
- data/lib/redis_queued_locks/acquirer/release_all_locks.rb +6 -2
- data/lib/redis_queued_locks/acquirer/release_locks_of.rb +6 -2
- data/lib/redis_queued_locks/acquirer.rb +1 -1
- data/lib/redis_queued_locks/client.rb +116 -44
- data/lib/redis_queued_locks/config.rb +93 -1
- data/lib/redis_queued_locks/resource.rb +124 -9
- data/lib/redis_queued_locks/swarm/swarm_element/threaded.rb +6 -5
- data/lib/redis_queued_locks/swarm/zombie_info.rb +6 -2
- data/lib/redis_queued_locks/version.rb +2 -2
- data/rbs_collection.lock.yaml +4 -0
- data/rbs_collection.yaml +2 -1
- data/redis_queued_locks.gemspec +21 -14
- 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 +12 -6
- data/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs +21 -14
- 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 +160 -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 +2 -2
- data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +5 -3
- data/sig/redis_queued_locks/acquirer/clear_dead_requests.rbs +14 -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/acquirer/queues.rbs +1 -1
- data/sig/redis_queued_locks/client.rbs +77 -7
- data/sig/redis_queued_locks/config.rbs +54 -1
- data/sig/redis_queued_locks/instrument/sampler.rbs +3 -1
- data/sig/redis_queued_locks/instrument/void_notifier.rbs +3 -1
- data/sig/redis_queued_locks/logging/sampler.rbs +3 -1
- data/sig/redis_queued_locks/resource.rbs +22 -12
- 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
- metadata +35 -13
- data/lib/redis_queued_locks/acquirer/lock_series_poc/instr_visitor.rb +0 -56
- data/lib/redis_queued_locks/acquirer/lock_series_poc/log_visitor.rb +0 -95
- data/lib/redis_queued_locks/acquirer/lock_series_poc.rb +0 -484
- /data/sig/redis_queued_locks/{acquier.rbs → acquirer.rbs} +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
use RedisQueuedLocks as RQL
|
|
2
|
+
|
|
3
|
+
module RedisQueuedLocks
|
|
4
|
+
module Acquirer
|
|
5
|
+
module LockSeries
|
|
6
|
+
module InstrVisitor
|
|
7
|
+
def self.lock_series_intermediate_lock_obtained: (
|
|
8
|
+
RQL::instrObj instrumenter,
|
|
9
|
+
bool instr_sampled,
|
|
10
|
+
String lock_key,
|
|
11
|
+
Array[String] lock_keys,
|
|
12
|
+
RQL::readWriteMode rw_mode,
|
|
13
|
+
Integer priority,
|
|
14
|
+
Integer ttl,
|
|
15
|
+
String acq_id,
|
|
16
|
+
String hst_id,
|
|
17
|
+
Integer|Float ts,
|
|
18
|
+
Integer|Float acq_time,
|
|
19
|
+
untyped? instrument
|
|
20
|
+
) -> void
|
|
21
|
+
|
|
22
|
+
def self.lock_series_lock_obtained: (
|
|
23
|
+
RQL::instrObj instrumenter,
|
|
24
|
+
bool instr_sampled,
|
|
25
|
+
String lock_key,
|
|
26
|
+
Array[String] lock_keys,
|
|
27
|
+
RQL::readWriteMode rw_mode,
|
|
28
|
+
Integer priority,
|
|
29
|
+
Integer ttl,
|
|
30
|
+
String acq_id,
|
|
31
|
+
String hst_id,
|
|
32
|
+
Integer|Float ts,
|
|
33
|
+
Integer|Float acq_time,
|
|
34
|
+
untyped? instrument
|
|
35
|
+
) -> void
|
|
36
|
+
|
|
37
|
+
def self.lock_series_lock_obtaining_failed: (
|
|
38
|
+
RQL::instrObj instrumenter,
|
|
39
|
+
bool instr_sampled,
|
|
40
|
+
String lock_key,
|
|
41
|
+
Array[String] lock_keys,
|
|
42
|
+
RQL::readWriteMode rw_mode,
|
|
43
|
+
Integer priority,
|
|
44
|
+
Integer ttl,
|
|
45
|
+
String acq_id,
|
|
46
|
+
String hst_id,
|
|
47
|
+
Integer|Float ts,
|
|
48
|
+
Integer|Float acq_time,
|
|
49
|
+
Symbol result,
|
|
50
|
+
untyped? instrument
|
|
51
|
+
) -> void
|
|
52
|
+
|
|
53
|
+
def self.lock_series_obtained: (
|
|
54
|
+
RQL::instrObj instrumenter,
|
|
55
|
+
bool instr_sampled,
|
|
56
|
+
Array[String] lock_keys,
|
|
57
|
+
RQL::readWriteMode rw_mode,
|
|
58
|
+
Integer priority,
|
|
59
|
+
Integer ttl,
|
|
60
|
+
String acq_id,
|
|
61
|
+
String hst_id,
|
|
62
|
+
Integer|Float ts,
|
|
63
|
+
Integer|Float acq_time,
|
|
64
|
+
Array[String] reentrant_lock_keys,
|
|
65
|
+
untyped? instrument
|
|
66
|
+
) -> void
|
|
67
|
+
|
|
68
|
+
def self.lock_series_hold_and_release: (
|
|
69
|
+
RQL::instrObj instrumenter,
|
|
70
|
+
bool instr_sampled,
|
|
71
|
+
Array[String] lock_keys,
|
|
72
|
+
RQL::readWriteMode rw_mode,
|
|
73
|
+
Integer priority,
|
|
74
|
+
Integer ttl,
|
|
75
|
+
String acq_id,
|
|
76
|
+
String hst_id,
|
|
77
|
+
Integer|Float ts,
|
|
78
|
+
Integer|Float acq_time,
|
|
79
|
+
Integer|Float hold_time,
|
|
80
|
+
Array[String] reentrant_lock_keys,
|
|
81
|
+
untyped? instrument
|
|
82
|
+
) -> void
|
|
83
|
+
|
|
84
|
+
def self.lock_series_obtaining_failed: (
|
|
85
|
+
RQL::instrObj instrumenter,
|
|
86
|
+
bool instr_sampled,
|
|
87
|
+
Array[String] lock_keys,
|
|
88
|
+
RQL::readWriteMode rw_mode,
|
|
89
|
+
Integer priority,
|
|
90
|
+
Integer ttl,
|
|
91
|
+
String acq_id,
|
|
92
|
+
String hst_id,
|
|
93
|
+
Integer|Float ts,
|
|
94
|
+
Integer|Float acq_time,
|
|
95
|
+
Symbol result,
|
|
96
|
+
String? failed_lock_key,
|
|
97
|
+
untyped? instrument
|
|
98
|
+
) -> void
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -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
|
|
@@ -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: (
|