redis_queued_locks 1.12.0 → 1.13.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/.rubocop.yml +4 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +42 -5
- data/LICENSE.txt +1 -1
- data/README.md +231 -203
- data/Rakefile +12 -4
- data/Steepfile +16 -0
- data/github_ci/ruby3.3.gemfile +17 -0
- data/github_ci/ruby3.3.gemfile.lock +217 -0
- data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/delay_execution.rb +4 -4
- data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb +40 -0
- data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/dequeue_from_lock_queue.rb +17 -8
- data/lib/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rb +166 -0
- data/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb +218 -0
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb +543 -0
- data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/try_to_lock.rb +126 -92
- data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/with_acq_timeout.rb +14 -13
- data/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb +76 -0
- data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/yield_expire.rb +43 -20
- data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock.rb +69 -42
- data/lib/redis_queued_locks/{acquier → acquirer}/clear_dead_requests.rb +5 -3
- data/lib/redis_queued_locks/{acquier → acquirer}/extend_lock_ttl.rb +4 -3
- data/lib/redis_queued_locks/{acquier → acquirer}/is_locked.rb +1 -1
- data/lib/redis_queued_locks/{acquier → acquirer}/is_queued.rb +1 -1
- data/lib/redis_queued_locks/{acquier → acquirer}/keys.rb +5 -5
- data/lib/redis_queued_locks/{acquier → acquirer}/lock_info.rb +9 -5
- data/lib/redis_queued_locks/{acquier → acquirer}/locks.rb +16 -3
- data/lib/redis_queued_locks/{acquier → acquirer}/queue_info.rb +8 -6
- data/lib/redis_queued_locks/{acquier → acquirer}/queues.rb +9 -2
- data/lib/redis_queued_locks/{acquier → acquirer}/release_all_locks.rb +23 -18
- data/lib/redis_queued_locks/{acquier → acquirer}/release_lock.rb +25 -19
- data/lib/redis_queued_locks/acquirer.rb +18 -0
- data/lib/redis_queued_locks/client.rb +164 -254
- data/lib/redis_queued_locks/config/dsl.rb +94 -0
- data/lib/redis_queued_locks/config.rb +231 -0
- data/lib/redis_queued_locks/data.rb +2 -0
- data/lib/redis_queued_locks/errors.rb +27 -11
- data/lib/redis_queued_locks/instrument.rb +11 -4
- data/lib/redis_queued_locks/logging/void_logger.rb +38 -1
- data/lib/redis_queued_locks/logging.rb +20 -5
- data/lib/redis_queued_locks/resource.rb +49 -11
- data/lib/redis_queued_locks/swarm/acquirers.rb +17 -16
- data/lib/redis_queued_locks/swarm/flush_zombies.rb +26 -25
- data/lib/redis_queued_locks/swarm/probe_hosts.rb +20 -19
- data/lib/redis_queued_locks/swarm/redis_client_builder.rb +3 -3
- data/lib/redis_queued_locks/swarm/supervisor.rb +19 -6
- data/lib/redis_queued_locks/swarm/swarm_element/isolated.rb +20 -18
- data/lib/redis_queued_locks/swarm/swarm_element/threaded.rb +35 -27
- data/lib/redis_queued_locks/swarm/zombie_info.rb +9 -9
- data/lib/redis_queued_locks/swarm.rb +20 -41
- data/lib/redis_queued_locks/utilities/lock.rb +4 -2
- data/lib/redis_queued_locks/utilities.rb +2 -2
- data/lib/redis_queued_locks/version.rb +2 -2
- data/lib/redis_queued_locks.rb +2 -2
- data/rbs_collection.lock.yaml +40 -0
- data/rbs_collection.yaml +16 -0
- data/redis_queued_locks.gemspec +22 -23
- data/sig/manifest.yml +7 -0
- data/sig/redis_queued_locks/acquier.rbs +4 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/delay_execution.rbs +9 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs +21 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +26 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rbs +71 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs +72 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs +179 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +48 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rbs +19 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs +41 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/yield_with_expire/log_visitor.rbs +32 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +51 -0
- data/sig/redis_queued_locks/acquirer/clear_dead_requests.rbs +28 -0
- data/sig/redis_queued_locks/acquirer/extend_lock_ttl.rbs +28 -0
- data/sig/redis_queued_locks/acquirer/is_locked.rbs +9 -0
- data/sig/redis_queued_locks/acquirer/is_queued.rbs +9 -0
- data/sig/redis_queued_locks/acquirer/keys.rbs +10 -0
- data/sig/redis_queued_locks/acquirer/lock_info.rbs +10 -0
- data/sig/redis_queued_locks/acquirer/locks.rbs +16 -0
- data/sig/redis_queued_locks/acquirer/queue_info.rbs +13 -0
- data/sig/redis_queued_locks/acquirer/queues.rbs +16 -0
- data/sig/redis_queued_locks/acquirer/release_all_locks.rbs +30 -0
- data/sig/redis_queued_locks/acquirer/release_lock.rbs +38 -0
- data/sig/redis_queued_locks/client.rbs +195 -0
- data/sig/redis_queued_locks/config/dsl.rbs +26 -0
- data/sig/redis_queued_locks/config.rbs +23 -0
- data/sig/redis_queued_locks/data.rbs +4 -0
- data/sig/redis_queued_locks/debugger/interface.rbs +9 -0
- data/sig/redis_queued_locks/debugger.rbs +13 -0
- data/sig/redis_queued_locks/errors.rbs +43 -0
- data/sig/redis_queued_locks/instrument/active_support.rbs +7 -0
- data/sig/redis_queued_locks/instrument/sampler.rbs +9 -0
- data/sig/redis_queued_locks/instrument/void_notifier.rbs +7 -0
- data/sig/redis_queued_locks/instrument.rbs +15 -0
- data/sig/redis_queued_locks/logging/sampler.rbs +9 -0
- data/sig/redis_queued_locks/logging/void_logger.rbs +15 -0
- data/sig/redis_queued_locks/logging.rbs +15 -0
- data/sig/redis_queued_locks/resource.rbs +42 -0
- data/sig/redis_queued_locks/swarm/acquirers.rbs +10 -0
- data/sig/redis_queued_locks/swarm/flush_zombies.rbs +13 -0
- data/sig/redis_queued_locks/swarm/probe_hosts.rbs +13 -0
- data/sig/redis_queued_locks/swarm/redis_client_builder.rbs +19 -0
- data/sig/redis_queued_locks/swarm/supervisor.rbs +26 -0
- data/sig/redis_queued_locks/swarm/swarm_element/isolated.rbs +52 -0
- data/sig/redis_queued_locks/swarm/swarm_element/threaded.rbs +61 -0
- data/sig/redis_queued_locks/swarm/swarm_element.rbs +8 -0
- data/sig/redis_queued_locks/swarm/zombie_info.rbs +24 -0
- data/sig/redis_queued_locks/swarm.rbs +41 -0
- data/sig/redis_queued_locks/utilities/lock.rbs +10 -0
- data/sig/redis_queued_locks/utilities.rbs +11 -0
- data/sig/redis_queued_locks/version.rbs +3 -0
- data/sig/redis_queued_locks.rbs +14 -0
- data/sig/vendor/active_support.rbs +9 -0
- data/sig/vendor/redis_client.rbs +39 -0
- data/sig/vendor/semantic_logger.rbs +4 -0
- metadata +96 -54
- data/lib/redis_queued_locks/acquier/acquire_lock/dequeue_from_lock_queue/log_visitor.rb +0 -40
- data/lib/redis_queued_locks/acquier/acquire_lock/instr_visitor.rb +0 -166
- data/lib/redis_queued_locks/acquier/acquire_lock/log_visitor.rb +0 -216
- data/lib/redis_queued_locks/acquier/acquire_lock/try_to_lock/log_visitor.rb +0 -541
- data/lib/redis_queued_locks/acquier/acquire_lock/yield_expire/log_visitor.rb +0 -76
- data/lib/redis_queued_locks/acquier.rb +0 -18
@@ -0,0 +1,71 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
|
3
|
+
module RedisQueuedLocks
|
4
|
+
module Acquirer
|
5
|
+
module AcquireLock
|
6
|
+
module InstrVisitor
|
7
|
+
def self.extendable_reentrant_lock_obtained: (
|
8
|
+
RQL::instrObj instrumenter,
|
9
|
+
bool instr_sampled,
|
10
|
+
String lock_key,
|
11
|
+
Integer? ttl,
|
12
|
+
String acq_id,
|
13
|
+
String hst_id,
|
14
|
+
Integer|Float ts,
|
15
|
+
Integer|Float acq_time,
|
16
|
+
untyped? instrument
|
17
|
+
) -> void
|
18
|
+
|
19
|
+
def self.reentrant_lock_obtained: (
|
20
|
+
RQL::instrObj instrumenter,
|
21
|
+
bool instr_sampled,
|
22
|
+
String lock_key,
|
23
|
+
Integer? ttl,
|
24
|
+
String acq_id,
|
25
|
+
String hst_id,
|
26
|
+
Integer|Float ts,
|
27
|
+
Integer|Float acq_time,
|
28
|
+
untyped? instrument
|
29
|
+
) -> void
|
30
|
+
|
31
|
+
def self.lock_obtained: (
|
32
|
+
RQL::instrObj instrumenter,
|
33
|
+
bool instr_sampled,
|
34
|
+
String lock_key,
|
35
|
+
Integer? ttl,
|
36
|
+
String acq_id,
|
37
|
+
String hst_id,
|
38
|
+
Integer|Float ts,
|
39
|
+
Integer|Float acq_time,
|
40
|
+
untyped? instrument
|
41
|
+
) -> void
|
42
|
+
|
43
|
+
def self.reentrant_lock_hold_completes: (
|
44
|
+
RQL::instrObj instrumenter,
|
45
|
+
bool instr_sampled,
|
46
|
+
String lock_key,
|
47
|
+
Integer? ttl,
|
48
|
+
String acq_id,
|
49
|
+
String hst_id,
|
50
|
+
Integer|Float ts,
|
51
|
+
Integer|Float acq_time,
|
52
|
+
Integer|Float hold_time,
|
53
|
+
untyped? instrument
|
54
|
+
) -> void
|
55
|
+
|
56
|
+
def self.lock_hold_and_release: (
|
57
|
+
RQL::instrObj instrumenter,
|
58
|
+
bool instr_sampled,
|
59
|
+
String lock_key,
|
60
|
+
Integer? ttl,
|
61
|
+
String acq_id,
|
62
|
+
String hst_id,
|
63
|
+
Integer|Float ts,
|
64
|
+
Integer|Float acq_time,
|
65
|
+
Integer|Float hold_time,
|
66
|
+
untyped? instrument
|
67
|
+
) -> void
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
|
3
|
+
module RedisQueuedLocks
|
4
|
+
module Acquirer
|
5
|
+
module AcquireLock
|
6
|
+
module LogVisitor
|
7
|
+
def self.start_lock_obtaining: (
|
8
|
+
RQL::loggerObj logger,
|
9
|
+
bool log_sampled,
|
10
|
+
String lock_key,
|
11
|
+
Integer queue_ttl,
|
12
|
+
String acquirer_id,
|
13
|
+
String host_id,
|
14
|
+
Symbol access_strategy
|
15
|
+
) -> void
|
16
|
+
|
17
|
+
def self.start_try_to_lock_cycle: (
|
18
|
+
RQL::loggerObj logger,
|
19
|
+
bool log_sampled,
|
20
|
+
String lock_key,
|
21
|
+
Integer queue_ttl,
|
22
|
+
String acquirer_id,
|
23
|
+
String host_id,
|
24
|
+
Symbol access_strategy
|
25
|
+
) -> void
|
26
|
+
|
27
|
+
def self.dead_score_reached__reset_acquirer_position: (
|
28
|
+
RQL::loggerObj logger,
|
29
|
+
bool log_sampled,
|
30
|
+
String lock_key,
|
31
|
+
Integer queue_ttl,
|
32
|
+
String acquirer_id,
|
33
|
+
String host_id,
|
34
|
+
Symbol access_strategy
|
35
|
+
) -> void
|
36
|
+
|
37
|
+
def self.extendable_reentrant_lock_obtained: (
|
38
|
+
RQL::loggerObj logger,
|
39
|
+
bool log_sampled,
|
40
|
+
String lock_key,
|
41
|
+
Integer queue_ttl,
|
42
|
+
String acquirer_id,
|
43
|
+
String host_id,
|
44
|
+
Integer|Float acq_time,
|
45
|
+
Symbol access_strategy
|
46
|
+
) -> void
|
47
|
+
|
48
|
+
def self.reentrant_lock_obtained: (
|
49
|
+
RQL::loggerObj logger,
|
50
|
+
bool log_sampled,
|
51
|
+
String lock_key,
|
52
|
+
Integer queue_ttl,
|
53
|
+
String acquirer_id,
|
54
|
+
String host_id,
|
55
|
+
Integer|Float acq_time,
|
56
|
+
Symbol access_strategy
|
57
|
+
) -> void
|
58
|
+
|
59
|
+
def self.lock_obtained: (
|
60
|
+
RQL::loggerObj logger,
|
61
|
+
bool log_sampled,
|
62
|
+
String lock_key,
|
63
|
+
Integer queue_ttl,
|
64
|
+
String acquirer_id,
|
65
|
+
String host_id,
|
66
|
+
Integer|Float acq_time,
|
67
|
+
Symbol access_strategy
|
68
|
+
) -> void
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
|
3
|
+
module RedisQueuedLocks
|
4
|
+
module Acquirer
|
5
|
+
module AcquireLock
|
6
|
+
module TryToLock
|
7
|
+
module LogVisitor
|
8
|
+
def self.start: (
|
9
|
+
RQL::loggerObj logger,
|
10
|
+
bool log_sampled,
|
11
|
+
bool log_lock_try,
|
12
|
+
String lock_key,
|
13
|
+
Integer queue_ttl,
|
14
|
+
String acquirer_id,
|
15
|
+
String host_id,
|
16
|
+
Symbol access_strategy
|
17
|
+
) -> void
|
18
|
+
|
19
|
+
def self.rconn_fetched: (
|
20
|
+
RQL::loggerObj logger,
|
21
|
+
bool log_sampled,
|
22
|
+
bool log_lock_try,
|
23
|
+
String lock_key,
|
24
|
+
Integer queue_ttl,
|
25
|
+
String acquirer_id,
|
26
|
+
String host_id,
|
27
|
+
Symbol access_strategy
|
28
|
+
) -> void
|
29
|
+
|
30
|
+
def self.same_process_conflict_detected: (
|
31
|
+
RQL::loggerObj logger,
|
32
|
+
bool log_sampled,
|
33
|
+
bool log_lock_try,
|
34
|
+
String lock_key,
|
35
|
+
Integer queue_ttl,
|
36
|
+
String acquirer_id,
|
37
|
+
String host_id,
|
38
|
+
Symbol access_strategy
|
39
|
+
) -> void
|
40
|
+
|
41
|
+
def self.same_process_conflict_analyzed: (
|
42
|
+
RQL::loggerObj logger,
|
43
|
+
bool log_sampled,
|
44
|
+
bool log_lock_try,
|
45
|
+
String lock_key,
|
46
|
+
Integer queue_ttl,
|
47
|
+
String acquirer_id,
|
48
|
+
String host_id,
|
49
|
+
Symbol access_strategy,
|
50
|
+
Symbol sp_conflict_status
|
51
|
+
) -> void
|
52
|
+
|
53
|
+
def self.reentrant_lock__extend_and_work_through: (
|
54
|
+
RQL::loggerObj logger,
|
55
|
+
bool log_sampled,
|
56
|
+
bool log_lock_try,
|
57
|
+
String lock_key,
|
58
|
+
Integer queue_ttl,
|
59
|
+
String acquirer_id,
|
60
|
+
String host_id,
|
61
|
+
Symbol access_strategy,
|
62
|
+
Symbol sp_conflict_status,
|
63
|
+
Integer? ttl,
|
64
|
+
::Float spc_processed_timestamp
|
65
|
+
) -> void
|
66
|
+
|
67
|
+
def self.reentrant_lock__work_through: (
|
68
|
+
RQL::loggerObj logger,
|
69
|
+
bool log_sampled,
|
70
|
+
bool log_lock_try,
|
71
|
+
String lock_key,
|
72
|
+
Integer queue_ttl,
|
73
|
+
String acquirer_id,
|
74
|
+
String host_id,
|
75
|
+
Symbol access_strategy,
|
76
|
+
Symbol sp_conflict_status,
|
77
|
+
::Float spc_processed_timestamp
|
78
|
+
) -> void
|
79
|
+
|
80
|
+
def self.single_process_lock_conflict__dead_lock: (
|
81
|
+
RQL::loggerObj logger,
|
82
|
+
bool log_sampled,
|
83
|
+
bool log_lock_try,
|
84
|
+
String lock_key,
|
85
|
+
Integer queue_ttl,
|
86
|
+
String acquirer_id,
|
87
|
+
String host_id,
|
88
|
+
Symbol access_strategy,
|
89
|
+
Symbol sp_conflict_status,
|
90
|
+
::Float spc_processed_timestamp
|
91
|
+
) -> void
|
92
|
+
|
93
|
+
def self.acq_added_to_queue: (
|
94
|
+
RQL::loggerObj logger,
|
95
|
+
bool log_sampled,
|
96
|
+
bool log_lock_try,
|
97
|
+
String lock_key,
|
98
|
+
Integer queue_ttl,
|
99
|
+
String acquirer_id,
|
100
|
+
String host_id,
|
101
|
+
Symbol access_strategy
|
102
|
+
) -> void
|
103
|
+
|
104
|
+
def self.remove_expired_acqs: (
|
105
|
+
RQL::loggerObj logger,
|
106
|
+
bool log_sampled,
|
107
|
+
bool log_lock_try,
|
108
|
+
String lock_key,
|
109
|
+
Integer queue_ttl,
|
110
|
+
String acquirer_id,
|
111
|
+
String host_id,
|
112
|
+
Symbol access_strategy
|
113
|
+
) -> void
|
114
|
+
|
115
|
+
def self.get_first_from_queue: (
|
116
|
+
RQL::loggerObj logger,
|
117
|
+
bool log_sampled,
|
118
|
+
bool log_lock_try,
|
119
|
+
String lock_key,
|
120
|
+
Integer queue_ttl,
|
121
|
+
String acquirer_id,
|
122
|
+
String host_id,
|
123
|
+
Symbol access_strategy,
|
124
|
+
String? waiting_acquirer
|
125
|
+
) -> void
|
126
|
+
|
127
|
+
def self.exit__queue_ttl_reached: (
|
128
|
+
RQL::loggerObj logger,
|
129
|
+
bool log_sampled,
|
130
|
+
bool log_lock_try,
|
131
|
+
String lock_key,
|
132
|
+
Integer queue_ttl,
|
133
|
+
String acquirer_id,
|
134
|
+
String host_id,
|
135
|
+
Symbol access_strategy
|
136
|
+
) -> void
|
137
|
+
|
138
|
+
def self.exit__no_first: (
|
139
|
+
RQL::loggerObj logger,
|
140
|
+
bool log_sampled,
|
141
|
+
bool log_lock_try,
|
142
|
+
String lock_key,
|
143
|
+
Integer queue_ttl,
|
144
|
+
String acquirer_id,
|
145
|
+
String host_id,
|
146
|
+
Symbol access_strategy,
|
147
|
+
String? waiting_acquirer,
|
148
|
+
Hash[String,untyped] current_lock_data
|
149
|
+
) -> void
|
150
|
+
|
151
|
+
def self.exit__lock_still_obtained: (
|
152
|
+
RQL::loggerObj logger,
|
153
|
+
bool log_sampled,
|
154
|
+
bool log_lock_try,
|
155
|
+
String lock_key,
|
156
|
+
Integer queue_ttl,
|
157
|
+
String acquirer_id,
|
158
|
+
String host_id,
|
159
|
+
Symbol access_strategy,
|
160
|
+
String? waiting_acquirer,
|
161
|
+
String locked_by_acquirer,
|
162
|
+
Hash[String,untyped] current_lock_data
|
163
|
+
) -> void
|
164
|
+
|
165
|
+
def self.obtain__free_to_acquire: (
|
166
|
+
RQL::loggerObj logger,
|
167
|
+
bool log_sampled,
|
168
|
+
bool log_lock_try,
|
169
|
+
String lock_key,
|
170
|
+
Integer queue_ttl,
|
171
|
+
String acquirer_id,
|
172
|
+
String host_id,
|
173
|
+
Symbol access_strategy
|
174
|
+
) -> void
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
use RedisClient as RC
|
3
|
+
|
4
|
+
module RedisQueuedLocks
|
5
|
+
module Acquirer
|
6
|
+
module AcquireLock
|
7
|
+
module TryToLock
|
8
|
+
EXTEND_LOCK_PTTL: String
|
9
|
+
|
10
|
+
# { ok: bool, result: Symbol }
|
11
|
+
# { ok: bool, result: Symbol }
|
12
|
+
# {
|
13
|
+
# ok: bool,
|
14
|
+
# result: {
|
15
|
+
# process: Symbol,
|
16
|
+
# lock_key: String,
|
17
|
+
# acq_id: String,
|
18
|
+
# hst_id: String,
|
19
|
+
# ts: Integer?,
|
20
|
+
# ttl: Integer?
|
21
|
+
# }
|
22
|
+
# }
|
23
|
+
|
24
|
+
def try_to_lock: (
|
25
|
+
RC::client redis,
|
26
|
+
RQL::loggerObj logger,
|
27
|
+
bool log_lock_try,
|
28
|
+
String lock_key,
|
29
|
+
Symbol read_write_mode,
|
30
|
+
String lock_key_queue,
|
31
|
+
String read_lock_key_queue,
|
32
|
+
String write_lock_key_queue,
|
33
|
+
String acquirer_id,
|
34
|
+
String host_id,
|
35
|
+
Integer|Float acquirer_position,
|
36
|
+
Integer? ttl,
|
37
|
+
Integer queue_ttl,
|
38
|
+
bool fail_fast,
|
39
|
+
Symbol conflict_strategy,
|
40
|
+
Symbol access_strategy,
|
41
|
+
Hash[String|Symbol,untyped]? meta,
|
42
|
+
bool log_sampled,
|
43
|
+
bool instr_sampled
|
44
|
+
) -> { ok: bool, result: Symbol|Hash[Symbol,untyped] }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
use RedisClient as RC
|
2
|
+
|
3
|
+
module RedisQueuedLocks
|
4
|
+
module Acquirer
|
5
|
+
module AcquireLock
|
6
|
+
module WithAcqTimeout
|
7
|
+
def with_acq_timeout: (
|
8
|
+
RC::client redis,
|
9
|
+
Integer? timeout,
|
10
|
+
String lock_key,
|
11
|
+
String lock_name,
|
12
|
+
bool raise_errors,
|
13
|
+
bool detailed_acq_timeout_error,
|
14
|
+
?on_timeout: Proc|nil
|
15
|
+
) { (?) -> untyped } -> untyped
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
use RedisClient as RC
|
3
|
+
|
4
|
+
module RedisQueuedLocks
|
5
|
+
module Acquirer
|
6
|
+
module AcquireLock
|
7
|
+
module YieldExpire
|
8
|
+
DECREASE_LOCK_PTTL: String
|
9
|
+
|
10
|
+
def yield_expire: (
|
11
|
+
RC::client redis,
|
12
|
+
RQL::loggerObj logger,
|
13
|
+
String lock_key,
|
14
|
+
String acquirer_id,
|
15
|
+
String host_id,
|
16
|
+
Symbol access_strategy,
|
17
|
+
bool timed,
|
18
|
+
Integer|Float ttl_shift,
|
19
|
+
Integer? ttl,
|
20
|
+
Integer queue_ttl,
|
21
|
+
Hash[String|Symbol,untyped]? meta,
|
22
|
+
bool log_sampled,
|
23
|
+
bool instr_sampled,
|
24
|
+
bool should_expire,
|
25
|
+
bool should_decrease
|
26
|
+
) ?{ (?) -> untyped } -> untyped?
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def yield_with_timeout: (
|
31
|
+
Float timeout,
|
32
|
+
String lock_key,
|
33
|
+
Integer? lock_ttl,
|
34
|
+
String acquirer_id,
|
35
|
+
String host_id,
|
36
|
+
Hash[String|Symbol,untyped]? meta,
|
37
|
+
) { (?) -> untyped } -> untyped
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
|
3
|
+
module RedisQueuedLocks
|
4
|
+
module Acquirer
|
5
|
+
module AcquireLock
|
6
|
+
module YieldExpire
|
7
|
+
module LogVisitor
|
8
|
+
def self.expire_lock: (
|
9
|
+
RQL::loggerObj logger,
|
10
|
+
bool log_sampled,
|
11
|
+
String lock_key,
|
12
|
+
Integer queue_ttl,
|
13
|
+
String acquirer_id,
|
14
|
+
String host_id,
|
15
|
+
Symbol access_strategy
|
16
|
+
) -> void
|
17
|
+
|
18
|
+
def self.decrease_lock: (
|
19
|
+
RQL::loggerObj logger,
|
20
|
+
bool log_sampled,
|
21
|
+
String lock_key,
|
22
|
+
Integer decreased_ttl,
|
23
|
+
Integer queue_ttl,
|
24
|
+
String acquirer_id,
|
25
|
+
String host_id,
|
26
|
+
Symbol access_strategy
|
27
|
+
) -> void
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
use RedisClient as RC
|
3
|
+
|
4
|
+
module RedisQueuedLocks
|
5
|
+
module Acquirer
|
6
|
+
module AcquireLock
|
7
|
+
extend RQL::Acquirer::AcquireLock::TryToLock
|
8
|
+
extend RQL::Acquirer::AcquireLock::DelayExecution
|
9
|
+
extend RQL::Acquirer::AcquireLock::YieldExpire
|
10
|
+
extend RQL::Acquirer::AcquireLock::WithAcqTimeout
|
11
|
+
extend RQL::Acquirer::AcquireLock::DequeueFromLockQueue
|
12
|
+
|
13
|
+
type acquireResult = ({ ok: bool, result: untyped }|untyped)
|
14
|
+
def self.acquire_lock: (
|
15
|
+
RC::client redis,
|
16
|
+
String lock_name,
|
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
|
+
timeout: Integer?,
|
24
|
+
timed: bool,
|
25
|
+
retry_count: Integer?,
|
26
|
+
retry_delay: Integer,
|
27
|
+
retry_jitter: Integer,
|
28
|
+
raise_errors: bool,
|
29
|
+
instrumenter: RQL::instrObj,
|
30
|
+
identity: String,
|
31
|
+
fail_fast: bool,
|
32
|
+
meta: Hash[String|Symbol,untyped]?,
|
33
|
+
detailed_acq_timeout_error: bool,
|
34
|
+
logger: RQL::loggerObj,
|
35
|
+
log_lock_try: bool,
|
36
|
+
instrument: untyped?,
|
37
|
+
conflict_strategy: Symbol,
|
38
|
+
read_write_mode: Symbol,
|
39
|
+
access_strategy: Symbol,
|
40
|
+
log_sampling_enabled: bool,
|
41
|
+
log_sampling_percent: Integer,
|
42
|
+
log_sampler: RQL::Logging::samplerObj,
|
43
|
+
log_sample_this: bool,
|
44
|
+
instr_sampling_enabled: bool,
|
45
|
+
instr_sampling_percent: Integer,
|
46
|
+
instr_sampler: RQL::Instrument::samplerObj,
|
47
|
+
instr_sample_this: bool
|
48
|
+
) ?{ (?) -> untyped } -> acquireResult
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
use RedisClient as RC
|
3
|
+
|
4
|
+
module RedisQueuedLocks
|
5
|
+
module Acquirer
|
6
|
+
module ClearDeadRequests
|
7
|
+
type clearResult = { ok: bool, result: { processed_queues: Set[String] } }
|
8
|
+
def self.clear_dead_requests: (
|
9
|
+
RC::client redis_client,
|
10
|
+
Integer scan_size,
|
11
|
+
Integer dead_ttl,
|
12
|
+
RQL::loggerObj logger,
|
13
|
+
RQL::instrObj instrumenter,
|
14
|
+
untyped? instrument,
|
15
|
+
bool log_sampling_enabled,
|
16
|
+
Integer log_sampling_percent,
|
17
|
+
RQL::Logging::samplerObj log_sampler,
|
18
|
+
bool log_sample_this,
|
19
|
+
bool instr_sampling_enabled,
|
20
|
+
Integer instr_sampling_percent,
|
21
|
+
RQL::Instrument::samplerObj instr_sampler,
|
22
|
+
bool instr_sample_this
|
23
|
+
) -> clearResult
|
24
|
+
|
25
|
+
private def self.each_lock_queue: (RC::client redis_client, Integer scan_size) { (String lock_queue) -> untyped } -> Enumerator[String]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
use RedisQueuedLocks as RQL
|
2
|
+
use RedisClient as RC
|
3
|
+
|
4
|
+
module RedisQueuedLocks
|
5
|
+
module Acquirer
|
6
|
+
module ExtendLockTTL
|
7
|
+
EXTEND_LOCK_PTTL: String
|
8
|
+
|
9
|
+
type extendResult = { ok: bool, result: Symbol }
|
10
|
+
def self.extend_lock_ttl: (
|
11
|
+
RC::client redis_client,
|
12
|
+
String lock_name,
|
13
|
+
Integer milliseconds,
|
14
|
+
RQL::loggerObj logger,
|
15
|
+
RQL::instrObj instrumenter,
|
16
|
+
untyped? instrument,
|
17
|
+
bool log_samling_enabled,
|
18
|
+
Integer log_sampling_percent,
|
19
|
+
RQL::Logging::samplerObj log_sampler,
|
20
|
+
bool sample_this,
|
21
|
+
bool instr_sampling_enabled,
|
22
|
+
Integer instr_sampling_percent,
|
23
|
+
RQL::Instrument::samplerObj instr_sampler,
|
24
|
+
bool instr_sample_this
|
25
|
+
) -> extendResult
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
use RedisClient as RC
|
2
|
+
|
3
|
+
module RedisQueuedLocks
|
4
|
+
module Acquirer
|
5
|
+
module Locks
|
6
|
+
type lockList = Set[String]
|
7
|
+
type locksInfo = Set[{ lock: String, status: Symbol, info: Hash[String,String|Float|Integer] }]
|
8
|
+
type locks = lockList | locksInfo
|
9
|
+
|
10
|
+
def self.locks: (RC::client redis_client, scan_size: Integer, with_info: bool) -> locks
|
11
|
+
|
12
|
+
private def self.scan_locks: (RC::client redis_client, Integer scan_size) -> lockList
|
13
|
+
private def self.extract_locks_info: (RC::client redis_client, Set[::String] lock_keys) -> locksInfo
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
use RedisClient as RC
|
2
|
+
|
3
|
+
module RedisQueuedLocks
|
4
|
+
module Acquirer
|
5
|
+
module QueueInfo
|
6
|
+
type queueInfo = {
|
7
|
+
'lock_queue' => String,
|
8
|
+
'queue' => Array[{ 'acq_id' => String, 'score' => Integer|Float }]
|
9
|
+
}
|
10
|
+
def self.queue_info: (RC::client redis_client, String lock_name) -> queueInfo?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
use RedisClient as RC
|
2
|
+
|
3
|
+
module RedisQueuedLocks
|
4
|
+
module Acquirer
|
5
|
+
module Queues
|
6
|
+
type queueList = Set[String]
|
7
|
+
type queuesInfo = Set[{ queue: String, requests: Array[Hash[String,Float]] }]
|
8
|
+
type queues = queueList | queuesInfo
|
9
|
+
|
10
|
+
def self.queues: (RC::client redis_client, scan_size: Integer, with_info: bool) -> queues
|
11
|
+
|
12
|
+
private def self.scan_queues: (RC::client redis_client, Integer scan_size) -> queueList
|
13
|
+
private def self.extract_queues_info: (RC::client redis_client, Set[String] lock_queues) -> queuesInfo
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|