redis_queued_locks 1.12.1 → 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 +32 -5
- data/LICENSE.txt +1 -1
- data/README.md +222 -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 -9
- 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 +42 -19
- data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock.rb +68 -41
- 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.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
@@ -4,120 +4,6 @@
|
|
4
4
|
# @since 1.0.0
|
5
5
|
# rubocop:disable Metrics/ClassLength
|
6
6
|
class RedisQueuedLocks::Client
|
7
|
-
# @since 1.0.0
|
8
|
-
include Qonfig::Configurable
|
9
|
-
|
10
|
-
configuration do
|
11
|
-
setting :retry_count, 3
|
12
|
-
setting :retry_delay, 200 # NOTE: in milliseconds
|
13
|
-
setting :retry_jitter, 25 # NOTE: in milliseconds
|
14
|
-
setting :try_to_lock_timeout, 10 # NOTE: in seconds
|
15
|
-
setting :default_lock_ttl, 5_000 # NOTE: in milliseconds
|
16
|
-
setting :default_queue_ttl, 15 # NOTE: in seconds
|
17
|
-
setting :detailed_acq_timeout_error, false
|
18
|
-
setting :lock_release_batch_size, 100
|
19
|
-
setting :key_extraction_batch_size, 500
|
20
|
-
setting :instrumenter, RedisQueuedLocks::Instrument::VoidNotifier
|
21
|
-
setting :uniq_identifier, -> { RedisQueuedLocks::Resource.calc_uniq_identity }
|
22
|
-
setting :logger, RedisQueuedLocks::Logging::VoidLogger
|
23
|
-
setting :log_lock_try, false
|
24
|
-
setting :dead_request_ttl, (1 * 24 * 60 * 60 * 1000) # NOTE: 1 day in milliseconds
|
25
|
-
setting :is_timed_by_default, false
|
26
|
-
setting :default_conflict_strategy, :wait_for_lock
|
27
|
-
setting :default_access_strategy, :queued
|
28
|
-
setting :log_sampling_enabled, false
|
29
|
-
setting :log_sampling_percent, 15
|
30
|
-
setting :log_sampler, RedisQueuedLocks::Logging::Sampler
|
31
|
-
setting :instr_sampling_enabled, false
|
32
|
-
setting :instr_sampling_percent, 15
|
33
|
-
setting :instr_sampler, RedisQueuedLocks::Instrument::Sampler
|
34
|
-
|
35
|
-
setting :swarm do
|
36
|
-
setting :auto_swarm, false
|
37
|
-
setting :supervisor do
|
38
|
-
setting :liveness_probing_period, 2 # NOTE: in seconds
|
39
|
-
end
|
40
|
-
setting :probe_hosts do
|
41
|
-
setting :enabled_for_swarm, true
|
42
|
-
setting :redis_config do
|
43
|
-
setting :sentinel, false
|
44
|
-
setting :pooled, false
|
45
|
-
setting :config, {}
|
46
|
-
setting :pool_config, {}
|
47
|
-
end
|
48
|
-
setting :probe_period, 2 # NOTE: in seconds
|
49
|
-
end
|
50
|
-
setting :flush_zombies do
|
51
|
-
setting :enabled_for_swarm, true
|
52
|
-
setting :redis_config do
|
53
|
-
setting :sentinel, false
|
54
|
-
setting :pooled, false
|
55
|
-
setting :config, {}
|
56
|
-
setting :pool_config, {}
|
57
|
-
end
|
58
|
-
setting :zombie_ttl, 15_000 # NOTE: in milliseconds
|
59
|
-
setting :zombie_lock_scan_size, 500
|
60
|
-
setting :zombie_queue_scan_size, 500
|
61
|
-
setting :zombie_flush_period, 10 # NOTE: in seconds
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
validate('swarm.auto_swarm', :boolean)
|
66
|
-
validate('swarm.visor.liveness_probing_period', :integer)
|
67
|
-
|
68
|
-
validate('swarm.probe_hosts.enabled_for_swarm', :boolean)
|
69
|
-
validate('swarm.probe_hosts.redis_config.sentinel', :boolean)
|
70
|
-
validate('swarm.probe_hosts.redis_config.pooled', :boolean)
|
71
|
-
validate('swarm.probe_hosts.redis_config.config', :hash)
|
72
|
-
validate('swarm.probe_hosts.redis_config.pool_config', :hash)
|
73
|
-
validate('swarm.probe_hosts.probe_period', :integer)
|
74
|
-
|
75
|
-
validate('swarm.flush_zombies.enabled_for_swarm', :boolean)
|
76
|
-
validate('swarm.flush_zombies.redis_config.sentinel', :boolean)
|
77
|
-
validate('swarm.flush_zombies.redis_config.pooled', :boolean)
|
78
|
-
validate('swarm.flush_zombies.redis_config.config', :hash)
|
79
|
-
validate('swarm.flush_zombies.redis_config.pool_config', :hash)
|
80
|
-
validate('swarm.flush_zombies.zombie_ttl', :integer)
|
81
|
-
validate('swarm.flush_zombies.zombie_lock_scan_size', :integer)
|
82
|
-
validate('swarm.flush_zombies.zombie_queue_scan_size', :integer)
|
83
|
-
validate('swarm.flush_zombies.zombie_flush_period', :integer)
|
84
|
-
|
85
|
-
validate('retry_count') { |val| val == nil || (val.is_a?(::Integer) && val >= 0) }
|
86
|
-
validate('retry_delay') { |val| val.is_a?(::Integer) && val >= 0 }
|
87
|
-
validate('retry_jitter') { |val| val.is_a?(::Integer) && val >= 0 }
|
88
|
-
validate('try_to_lock_timeout') { |val| val == nil || (val.is_a?(::Integer) && val >= 0) }
|
89
|
-
validate('default_lock_tt', :integer)
|
90
|
-
validate('default_queue_ttl', :integer)
|
91
|
-
validate('detailed_acq_timeout_error', :boolean)
|
92
|
-
validate('lock_release_batch_size', :integer)
|
93
|
-
validate('instrumenter') { |val| RedisQueuedLocks::Instrument.valid_interface?(val) }
|
94
|
-
validate('uniq_identifier', :proc)
|
95
|
-
validate('logger') { |val| RedisQueuedLocks::Logging.valid_interface?(val) }
|
96
|
-
validate('log_lock_try', :boolean)
|
97
|
-
validate('dead_request_ttl') { |val| val.is_a?(::Integer) && val > 0 }
|
98
|
-
validate('is_timed_by_default', :boolean)
|
99
|
-
validate('log_sampler') { |val| RedisQueuedLocks::Logging.valid_sampler?(val) }
|
100
|
-
validate('log_sampling_enabled', :boolean)
|
101
|
-
validate('log_sampling_percent') { |val| val.is_a?(::Integer) && val >= 0 && val <= 100 }
|
102
|
-
validate('instr_sampling_enabled', :boolean)
|
103
|
-
validate('instr_sampling_percent') { |val| val.is_a?(::Integer) && val >= 0 && val <= 100 }
|
104
|
-
validate('instr_sampler') { |val| RedisQueuedLocks::Instrument.valid_sampler?(val) }
|
105
|
-
validate('default_conflict_strategy') do |val|
|
106
|
-
# rubocop:disable Layout/MultilineOperationIndentation
|
107
|
-
val == :work_through ||
|
108
|
-
val == :extendable_work_through ||
|
109
|
-
val == :wait_for_lock ||
|
110
|
-
val == :dead_locking
|
111
|
-
# rubocop:enable Layout/MultilineOperationIndentation
|
112
|
-
end
|
113
|
-
validate('default_access_strategy') do |val|
|
114
|
-
# rubocop:disable Layout/MultilineOperationIndentation
|
115
|
-
val == :queued ||
|
116
|
-
val == :random
|
117
|
-
# rubocop:enable Layout/MultilineOperationIndentation
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
7
|
# @return [RedisClient]
|
122
8
|
#
|
123
9
|
# @api private
|
@@ -138,20 +24,37 @@ class RedisQueuedLocks::Client
|
|
138
24
|
# @since 1.9.0
|
139
25
|
attr_reader :swarm
|
140
26
|
|
27
|
+
# @return [RedisQueuedLocks::Config]
|
28
|
+
#
|
29
|
+
# @api public
|
30
|
+
# @since [1.13.0]
|
31
|
+
attr_reader :config
|
32
|
+
|
141
33
|
# @param redis_client [RedisClient]
|
142
|
-
# Redis connection manager, which will be used for the lock
|
34
|
+
# Redis connection manager, which will be used for the lock acquirerment and distribution.
|
143
35
|
# It should be an instance of RedisClient.
|
144
|
-
# @param
|
36
|
+
# @param configuration [Block]
|
145
37
|
# Custom configs for in-runtime configuration.
|
146
38
|
# @return [void]
|
147
39
|
#
|
148
40
|
# @api public
|
149
41
|
# @since 1.0.0
|
150
|
-
|
151
|
-
|
152
|
-
@
|
42
|
+
# @version 1.13.0
|
43
|
+
def initialize(redis_client, &configuration)
|
44
|
+
@config = RedisQueuedLocks::Config.new(&configuration)
|
45
|
+
@uniq_identity = config['uniq_identifier'].call #: String
|
153
46
|
@redis_client = redis_client
|
154
|
-
@swarm = RedisQueuedLocks::Swarm.new(self)
|
47
|
+
@swarm = RedisQueuedLocks::Swarm.new(self)
|
48
|
+
@swarm.swarm! if config['swarm.auto_swarm']
|
49
|
+
end
|
50
|
+
|
51
|
+
# @param configuration [Block]
|
52
|
+
# @return [void]
|
53
|
+
#
|
54
|
+
# @api public
|
55
|
+
# @since [1.13.0]
|
56
|
+
def configure(&configuration)
|
57
|
+
config.configure(&configuration)
|
155
58
|
end
|
156
59
|
|
157
60
|
# @return [Hash<Symbol,Boolean|Symbol>]
|
@@ -175,7 +78,7 @@ class RedisQueuedLocks::Client
|
|
175
78
|
#
|
176
79
|
# @api public
|
177
80
|
# @since 1.9.0
|
178
|
-
def swarm_info(zombie_ttl: config[
|
81
|
+
def swarm_info(zombie_ttl: config['swarm.flush_zombies.zombie_ttl']) # steep:ignore
|
179
82
|
swarm.swarm_info(zombie_ttl:)
|
180
83
|
end
|
181
84
|
|
@@ -204,9 +107,9 @@ class RedisQueuedLocks::Client
|
|
204
107
|
# @api public
|
205
108
|
# @since 1.9.0
|
206
109
|
def flush_zombies(
|
207
|
-
zombie_ttl: config[
|
208
|
-
lock_scan_size: config[
|
209
|
-
queue_scan_size: config[
|
110
|
+
zombie_ttl: config['swarm.flush_zombies.zombie_ttl'], # steep:ignore
|
111
|
+
lock_scan_size: config['swarm.flush_zombies.zombie_lock_scan_size'], # steep:ignore
|
112
|
+
queue_scan_size: config['swarm.flush_zombies.zombie_queue_scan_size'] # steep:ignore
|
210
113
|
)
|
211
114
|
swarm.flush_zombies(zombie_ttl:, lock_scan_size:, queue_scan_size:)
|
212
115
|
end
|
@@ -218,8 +121,8 @@ class RedisQueuedLocks::Client
|
|
218
121
|
# @api public
|
219
122
|
# @since 1.9.0
|
220
123
|
def zombie_locks(
|
221
|
-
zombie_ttl: config[
|
222
|
-
lock_scan_size: config[
|
124
|
+
zombie_ttl: config['swarm.flush_zombies.zombie_ttl'], # steep:ignore
|
125
|
+
lock_scan_size: config['swarm.flush_zombies.zombie_lock_scan_size'] # steep:ignore
|
223
126
|
)
|
224
127
|
swarm.zombie_locks(zombie_ttl:, lock_scan_size:)
|
225
128
|
end
|
@@ -230,11 +133,11 @@ class RedisQueuedLocks::Client
|
|
230
133
|
#
|
231
134
|
# @api ppublic
|
232
135
|
# @since 1.9.0
|
233
|
-
def
|
234
|
-
zombie_ttl: config[
|
235
|
-
lock_scan_size: config[
|
136
|
+
def zombie_acquirers(
|
137
|
+
zombie_ttl: config['swarm.flush_zombies.zombie_ttl'], # steep:ignore
|
138
|
+
lock_scan_size: config['swarm.flush_zombies.zombie_lock_scan_size'] # steep:ignore
|
236
139
|
)
|
237
|
-
swarm.
|
140
|
+
swarm.zombie_acquirers(zombie_ttl:, lock_scan_size:)
|
238
141
|
end
|
239
142
|
|
240
143
|
# @option zombie_ttl [Integer]
|
@@ -242,22 +145,22 @@ class RedisQueuedLocks::Client
|
|
242
145
|
#
|
243
146
|
# @api public
|
244
147
|
# @since 1.9.0
|
245
|
-
def zombie_hosts(zombie_ttl: config[
|
148
|
+
def zombie_hosts(zombie_ttl: config['swarm.flush_zombies.zombie_ttl']) # steep:ignore
|
246
149
|
swarm.zombie_hosts(zombie_ttl:)
|
247
150
|
end
|
248
151
|
|
249
152
|
# @return [Hash<Symbol,Set<String>>]
|
250
153
|
# Format: {
|
251
154
|
# zombie_hosts: <Set<String>>,
|
252
|
-
#
|
155
|
+
# zombie_acquirers: <Set<String>>,
|
253
156
|
# zombie_locks: <Set<String>>
|
254
157
|
# }
|
255
158
|
#
|
256
159
|
# @api public
|
257
160
|
# @since 1.9.0
|
258
161
|
def zombies_info(
|
259
|
-
zombie_ttl: config[
|
260
|
-
lock_scan_size: config[
|
162
|
+
zombie_ttl: config['swarm.flush_zombies.zombie_ttl'], # steep:ignore
|
163
|
+
lock_scan_size: config['swarm.flush_zombies.zombie_ttl'] # steep:ignore
|
261
164
|
)
|
262
165
|
swarm.zombies_info(zombie_ttl:, lock_scan_size:)
|
263
166
|
end
|
@@ -294,13 +197,15 @@ class RedisQueuedLocks::Client
|
|
294
197
|
# - The conflict strategy mode for cases when the process that obtained the lock
|
295
198
|
# want to acquire this lock again;
|
296
199
|
# - By default uses `:wait_for_lock` strategy;
|
297
|
-
# - pre-confured in `config[
|
200
|
+
# - pre-confured in `config['default_conflict_strategy']`;
|
298
201
|
# - Supports:
|
299
202
|
# - `:work_through` - continue working under the lock without lock's TTL extension;
|
300
203
|
# - `:extendable_work_through` - continue working under the lock with lock's TTL extension;
|
301
204
|
# - `:wait_for_lock` - (default) - work in classic way
|
302
205
|
# (with timeouts, retry delays, retry limits, etc - in classic way :));
|
303
206
|
# - `:dead_locking` - fail with deadlock exception;
|
207
|
+
# @option read_write_mode [Symbol]
|
208
|
+
# - ?
|
304
209
|
# @option access_strategy [Symbol]
|
305
210
|
# - The way in which the lock will be obtained;
|
306
211
|
# - By default it uses `:queued` strategy;
|
@@ -310,7 +215,7 @@ class RedisQueuedLocks::Client
|
|
310
215
|
# - `:random` (RANDOM): obtain a lock without checking the positions in the queue
|
311
216
|
# (but with checking the limist, retries, timeouts and so on). if lock is
|
312
217
|
# free to obtain - it will be obtained;
|
313
|
-
# - pre-configured in `config[
|
218
|
+
# - pre-configured in `config['default_access_strategy']`;
|
314
219
|
# @option meta [NilClass,Hash<String|Symbol,Any>]
|
315
220
|
# - A custom metadata wich will be passed to the lock data in addition to the existing data;
|
316
221
|
# - Metadata can not contain reserved lock data keys;
|
@@ -334,20 +239,20 @@ class RedisQueuedLocks::Client
|
|
334
239
|
# and moved from the lock queue after the error moment and before the error message build;
|
335
240
|
# - You should consider the async nature of this error message and should use received data
|
336
241
|
# from error message correspondingly;
|
337
|
-
# - pre-configred in `config[
|
242
|
+
# - pre-configred in `config['detailed_acq_timeout_error']`;
|
338
243
|
# @option logger [::Logger,#debug]
|
339
|
-
# - Logger object used from the configuration layer (see config[
|
244
|
+
# - Logger object used from the configuration layer (see config['logger']);
|
340
245
|
# - See `RedisQueuedLocks::Logging::VoidLogger` for example;
|
341
246
|
# - Supports `SemanticLogger::Logger` (see "semantic_logger" gem)
|
342
247
|
# @option log_lock_try [Boolean]
|
343
248
|
# - should be logged the each try of lock acquiring (a lot of logs can
|
344
249
|
# be generated depending on your retry configurations);
|
345
|
-
# - see `config[
|
250
|
+
# - see `config['log_lock_try']`;
|
346
251
|
# @option instrumenter [#notify]
|
347
252
|
# - Custom instrumenter that will be invoked via #notify method with `event` and `payload` data;
|
348
253
|
# - See RedisQueuedLocks::Instrument::ActiveSupport for examples and implementation details;
|
349
254
|
# - See [Instrumentation](#instrumentation) section of docs;
|
350
|
-
# - pre-configured in `config[
|
255
|
+
# - pre-configured in `config['isntrumenter']` with void notifier
|
351
256
|
# (`RedisQueuedLocks::Instrumenter::VoidNotifier`);
|
352
257
|
# @option instrument [NilClass,Any]
|
353
258
|
# - Custom instrumentation data wich will be passed to the instrumenter's payload
|
@@ -355,15 +260,15 @@ class RedisQueuedLocks::Client
|
|
355
260
|
# @option log_sampling_enabled [Boolean]
|
356
261
|
# - enables <log sampling>: only the configured percent of RQL cases will be logged;
|
357
262
|
# - disabled by default;
|
358
|
-
# - works in tandem with <config
|
263
|
+
# - works in tandem with <config['log_sampling_percent'] and <config['log_sampler']>;
|
359
264
|
# @option log_sampling_percent [Integer]
|
360
265
|
# - the percent of cases that should be logged;
|
361
|
-
# - take an effect when <config
|
362
|
-
# - works in tandem with <config
|
266
|
+
# - take an effect when <config['log_sampling_enalbed']> is true;
|
267
|
+
# - works in tandem with <config['log_sampling_enabled']> and <config['log_sampler']> configs;
|
363
268
|
# @option log_sampler [#sampling_happened?,Module<RedisQueuedLocks::Logging::Sampler>]
|
364
269
|
# - percent-based log sampler that decides should be RQL case logged or not;
|
365
|
-
# - works in tandem with <config
|
366
|
-
# <config
|
270
|
+
# - works in tandem with <config['log_sampling_enabled']> and
|
271
|
+
# <config['log_sampling_percent']> configs;
|
367
272
|
# - based on the ultra simple percent-based (weight-based) algorithm that uses SecureRandom.rand
|
368
273
|
# method so the algorithm error is ~(0%..13%);
|
369
274
|
# - you can provide your own log sampler with bettter algorithm that should realize
|
@@ -376,15 +281,16 @@ class RedisQueuedLocks::Client
|
|
376
281
|
# - enables <instrumentaion sampling>: only the configured percent
|
377
282
|
# of RQL cases will be instrumented;
|
378
283
|
# - disabled by default;
|
379
|
-
# - works in tandem with <config
|
284
|
+
# - works in tandem with <config['instr_sampling_percent']> and <config['instr_sampler']>;
|
380
285
|
# @option instr_sampling_percent [Integer]
|
381
286
|
# - the percent of cases that should be instrumented;
|
382
|
-
# - take an effect when <config
|
383
|
-
# - works in tandem with <config
|
287
|
+
# - take an effect when <config['instr_sampling_enalbed']> is true;
|
288
|
+
# - works in tandem with <config['instr_sampling_enabled']>
|
289
|
+
# and <config['instr_sampler']> configs;
|
384
290
|
# @option instr_sampler [#sampling_happened?,Module<RedisQueuedLocks::Instrument::Sampler>]
|
385
291
|
# - percent-based log sampler that decides should be RQL case instrumented or not;
|
386
|
-
# - works in tandem with <config
|
387
|
-
# <config
|
292
|
+
# - works in tandem with <config['instr_sampling_enabled']> and
|
293
|
+
# <config['instr_sampling_percent']> configs;
|
388
294
|
# - based on the ultra simple percent-based (weight-based) algorithm that uses SecureRandom.rand
|
389
295
|
# method so the algorithm error is ~(0%..13%);
|
390
296
|
# - you can provide your own log sampler with bettter algorithm that should realize
|
@@ -396,45 +302,46 @@ class RedisQueuedLocks::Client
|
|
396
302
|
# - makes sense when instrumentation sampling is enabled;
|
397
303
|
# @param block [Block]
|
398
304
|
# A block of code that should be executed after the successfully acquired lock.
|
399
|
-
# @return [
|
305
|
+
# @return [Hash<Symbol,Any>,yield]
|
400
306
|
# - Format: { ok: true/false, result: Symbol/Hash }.
|
401
307
|
# - If block is given the result of block's yeld will be returned.
|
402
308
|
#
|
403
309
|
# @api public
|
404
310
|
# @since 1.0.0
|
405
|
-
# @version 1.
|
311
|
+
# @version 1.13.0
|
406
312
|
# rubocop:disable Metrics/MethodLength
|
407
313
|
def lock(
|
408
314
|
lock_name,
|
409
|
-
ttl: config[
|
410
|
-
queue_ttl: config[
|
411
|
-
timeout: config[
|
412
|
-
timed: config[
|
413
|
-
retry_count: config[
|
414
|
-
retry_delay: config[
|
415
|
-
retry_jitter: config[
|
315
|
+
ttl: config['default_lock_ttl'], # steep:ignore
|
316
|
+
queue_ttl: config['default_queue_ttl'], # steep:ignore
|
317
|
+
timeout: config['try_to_lock_timeout'], # steep:ignore
|
318
|
+
timed: config['is_timed_by_default'], # steep:ignore
|
319
|
+
retry_count: config['retry_count'], # steep:ignore
|
320
|
+
retry_delay: config['retry_delay'], # steep:ignore
|
321
|
+
retry_jitter: config['retry_jitter'], # steep:ignore
|
416
322
|
raise_errors: false,
|
417
323
|
fail_fast: false,
|
418
|
-
conflict_strategy: config[
|
419
|
-
|
324
|
+
conflict_strategy: config['default_conflict_strategy'], # steep:ignore
|
325
|
+
read_write_mode: :write,
|
326
|
+
access_strategy: config['default_access_strategy'], # steep:ignore
|
420
327
|
identity: uniq_identity,
|
421
328
|
meta: nil,
|
422
|
-
detailed_acq_timeout_error: config[
|
423
|
-
logger: config[
|
424
|
-
log_lock_try: config[
|
425
|
-
instrumenter: config[
|
329
|
+
detailed_acq_timeout_error: config['detailed_acq_timeout_error'], # steep:ignore
|
330
|
+
logger: config['logger'], # steep:ignore
|
331
|
+
log_lock_try: config['log_lock_try'], # steep:ignore
|
332
|
+
instrumenter: config['instrumenter'], # steep:ignore
|
426
333
|
instrument: nil,
|
427
|
-
log_sampling_enabled: config[
|
428
|
-
log_sampling_percent: config[
|
429
|
-
log_sampler: config[
|
334
|
+
log_sampling_enabled: config['log_sampling_enabled'], # steep:ignore
|
335
|
+
log_sampling_percent: config['log_sampling_percent'], # steep:ignore
|
336
|
+
log_sampler: config['log_sampler'], # steep:ignore
|
430
337
|
log_sample_this: false,
|
431
|
-
instr_sampling_enabled: config[
|
432
|
-
instr_sampling_percent: config[
|
433
|
-
instr_sampler: config[
|
338
|
+
instr_sampling_enabled: config['instr_sampling_enabled'], # steep:ignore
|
339
|
+
instr_sampling_percent: config['instr_sampling_percent'], # steep:ignore
|
340
|
+
instr_sampler: config['instr_sampler'], # steep:ignore
|
434
341
|
instr_sample_this: false,
|
435
342
|
&block
|
436
343
|
)
|
437
|
-
RedisQueuedLocks::
|
344
|
+
RedisQueuedLocks::Acquirer::AcquireLock.acquire_lock(
|
438
345
|
redis_client,
|
439
346
|
lock_name,
|
440
347
|
process_id: RedisQueuedLocks::Resource.get_process_id,
|
@@ -453,6 +360,7 @@ class RedisQueuedLocks::Client
|
|
453
360
|
identity:,
|
454
361
|
fail_fast:,
|
455
362
|
conflict_strategy:,
|
363
|
+
read_write_mode:,
|
456
364
|
access_strategy:,
|
457
365
|
meta:,
|
458
366
|
detailed_acq_timeout_error:,
|
@@ -476,34 +384,35 @@ class RedisQueuedLocks::Client
|
|
476
384
|
#
|
477
385
|
# @api public
|
478
386
|
# @since 1.0.0
|
479
|
-
# @version 1.
|
387
|
+
# @version 1.13.0
|
480
388
|
# rubocop:disable Metrics/MethodLength
|
481
389
|
def lock!(
|
482
390
|
lock_name,
|
483
|
-
ttl: config[
|
484
|
-
queue_ttl: config[
|
485
|
-
timeout: config[
|
486
|
-
timed: config[
|
487
|
-
retry_count: config[
|
488
|
-
retry_delay: config[
|
489
|
-
retry_jitter: config[
|
391
|
+
ttl: config['default_lock_ttl'], # steep:ignore
|
392
|
+
queue_ttl: config['default_queue_ttl'], # steep:ignore
|
393
|
+
timeout: config['try_to_lock_timeout'], # steep:ignore
|
394
|
+
timed: config['is_timed_by_default'], # steep:ignore
|
395
|
+
retry_count: config['retry_count'], # steep:ignore
|
396
|
+
retry_delay: config['retry_delay'], # steep:ignore
|
397
|
+
retry_jitter: config['retry_jitter'], # steep:ignore
|
490
398
|
fail_fast: false,
|
491
|
-
conflict_strategy: config[
|
492
|
-
|
399
|
+
conflict_strategy: config['default_conflict_strategy'], # steep:ignore
|
400
|
+
read_write_mode: :write,
|
401
|
+
access_strategy: config['default_access_strategy'], # steep:ignore
|
493
402
|
identity: uniq_identity,
|
494
|
-
instrumenter: config[
|
403
|
+
instrumenter: config['instrumenter'], # steep:ignore
|
495
404
|
meta: nil,
|
496
|
-
detailed_acq_timeout_error: config[
|
497
|
-
logger: config[
|
498
|
-
log_lock_try: config[
|
405
|
+
detailed_acq_timeout_error: config['detailed_acq_timeout_error'], # steep:ignore
|
406
|
+
logger: config['logger'], # steep:ignore
|
407
|
+
log_lock_try: config['log_lock_try'], # steep:ignore
|
499
408
|
instrument: nil,
|
500
|
-
log_sampling_enabled: config[
|
501
|
-
log_sampling_percent: config[
|
502
|
-
log_sampler: config[
|
409
|
+
log_sampling_enabled: config['log_sampling_enabled'], # steep:ignore
|
410
|
+
log_sampling_percent: config['log_sampling_percent'], # steep:ignore
|
411
|
+
log_sampler: config['log_sampler'], # steep:ignore
|
503
412
|
log_sample_this: false,
|
504
|
-
instr_sampling_enabled: config[
|
505
|
-
instr_sampling_percent: config[
|
506
|
-
instr_sampler: config[
|
413
|
+
instr_sampling_enabled: config['instr_sampling_enabled'], # steep:ignore
|
414
|
+
instr_sampling_percent: config['instr_sampling_percent'], # steep:ignore
|
415
|
+
instr_sampler: config['instr_sampler'], # steep:ignore
|
507
416
|
instr_sample_this: false,
|
508
417
|
&block
|
509
418
|
)
|
@@ -526,6 +435,7 @@ class RedisQueuedLocks::Client
|
|
526
435
|
instrument:,
|
527
436
|
instrumenter:,
|
528
437
|
conflict_strategy:,
|
438
|
+
read_write_mode:,
|
529
439
|
access_strategy:,
|
530
440
|
log_sampling_enabled:,
|
531
441
|
log_sampling_percent:,
|
@@ -552,7 +462,7 @@ class RedisQueuedLocks::Client
|
|
552
462
|
# @option instr_sampling_percent [Integer]
|
553
463
|
# @option instr_sampler [#sampling_happened?,Module<RedisQueuedLocks::Instrument::Sampler>]
|
554
464
|
# @option instr_sample_this [Boolean]
|
555
|
-
# @return [
|
465
|
+
# @return [Hash<Symbol,Any>]
|
556
466
|
# Format: {
|
557
467
|
# ok: true/false,
|
558
468
|
# result: {
|
@@ -569,19 +479,19 @@ class RedisQueuedLocks::Client
|
|
569
479
|
# @version 1.6.0
|
570
480
|
def unlock(
|
571
481
|
lock_name,
|
572
|
-
logger: config[
|
573
|
-
instrumenter: config[
|
482
|
+
logger: config['logger'], # steep:ignore
|
483
|
+
instrumenter: config['instrumenter'], # steep:ignore
|
574
484
|
instrument: nil,
|
575
|
-
log_sampling_enabled: config[
|
576
|
-
log_sampling_percent: config[
|
577
|
-
log_sampler: config[
|
485
|
+
log_sampling_enabled: config['log_sampling_enabled'], # steep:ignore
|
486
|
+
log_sampling_percent: config['log_sampling_percent'], # steep:ignore
|
487
|
+
log_sampler: config['log_sampler'], # steep:ignore
|
578
488
|
log_sample_this: false,
|
579
|
-
instr_sampling_enabled: config[
|
580
|
-
instr_sampling_percent: config[
|
581
|
-
instr_sampler: config[
|
489
|
+
instr_sampling_enabled: config['instr_sampling_enabled'], # steep:ignore
|
490
|
+
instr_sampling_percent: config['instr_sampling_percent'], # steep:ignore
|
491
|
+
instr_sampler: config['instr_sampler'], # steep:ignore
|
582
492
|
instr_sample_this: false
|
583
493
|
)
|
584
|
-
RedisQueuedLocks::
|
494
|
+
RedisQueuedLocks::Acquirer::ReleaseLock.release_lock(
|
585
495
|
redis_client,
|
586
496
|
lock_name,
|
587
497
|
instrumenter,
|
@@ -604,7 +514,7 @@ class RedisQueuedLocks::Client
|
|
604
514
|
# @api public
|
605
515
|
# @since 1.0.0
|
606
516
|
def locked?(lock_name)
|
607
|
-
RedisQueuedLocks::
|
517
|
+
RedisQueuedLocks::Acquirer::IsLocked.locked?(redis_client, lock_name)
|
608
518
|
end
|
609
519
|
|
610
520
|
# @param lock_name [String]
|
@@ -613,7 +523,7 @@ class RedisQueuedLocks::Client
|
|
613
523
|
# @api public
|
614
524
|
# @since 1.0.0
|
615
525
|
def queued?(lock_name)
|
616
|
-
RedisQueuedLocks::
|
526
|
+
RedisQueuedLocks::Acquirer::IsQueued.queued?(redis_client, lock_name)
|
617
527
|
end
|
618
528
|
|
619
529
|
# @param lock_name [String]
|
@@ -622,7 +532,7 @@ class RedisQueuedLocks::Client
|
|
622
532
|
# @api public
|
623
533
|
# @since 1.0.0
|
624
534
|
def lock_info(lock_name)
|
625
|
-
RedisQueuedLocks::
|
535
|
+
RedisQueuedLocks::Acquirer::LockInfo.lock_info(redis_client, lock_name)
|
626
536
|
end
|
627
537
|
|
628
538
|
# @param lock_name [String]
|
@@ -631,7 +541,7 @@ class RedisQueuedLocks::Client
|
|
631
541
|
# @api public
|
632
542
|
# @since 1.0.0
|
633
543
|
def queue_info(lock_name)
|
634
|
-
RedisQueuedLocks::
|
544
|
+
RedisQueuedLocks::Acquirer::QueueInfo.queue_info(redis_client, lock_name)
|
635
545
|
end
|
636
546
|
|
637
547
|
# Retrun the current acquirer identifier.
|
@@ -640,10 +550,10 @@ class RedisQueuedLocks::Client
|
|
640
550
|
# @option thread_id [Integer,Any] Thread identifier.
|
641
551
|
# @option fiber_id [Integer,Any] Fiber identifier.
|
642
552
|
# @option ractor_id [Integer,Any] Ractor identifier.
|
643
|
-
# @option identity [String] Unique per-process string. See `config[
|
553
|
+
# @option identity [String] Unique per-process string. See `config['uniq_identifier']`.
|
644
554
|
# @return [String]
|
645
555
|
#
|
646
|
-
# @see RedisQueuedLocks::Resource.
|
556
|
+
# @see RedisQueuedLocks::Resource.acquirer_identifier
|
647
557
|
# @see RedisQueuedLocks::Resource.get_process_id
|
648
558
|
# @see RedisQueuedLocks::Resource.get_thread_id
|
649
559
|
# @see RedisQueuedLocks::Resource.get_fiber_id
|
@@ -652,14 +562,14 @@ class RedisQueuedLocks::Client
|
|
652
562
|
#
|
653
563
|
# @api public
|
654
564
|
# @since 1.8.0
|
655
|
-
def
|
565
|
+
def current_acquirer_id(
|
656
566
|
process_id: RedisQueuedLocks::Resource.get_process_id,
|
657
567
|
thread_id: RedisQueuedLocks::Resource.get_thread_id,
|
658
568
|
fiber_id: RedisQueuedLocks::Resource.get_fiber_id,
|
659
569
|
ractor_id: RedisQueuedLocks::Resource.get_ractor_id,
|
660
570
|
identity: uniq_identity
|
661
571
|
)
|
662
|
-
RedisQueuedLocks::Resource.
|
572
|
+
RedisQueuedLocks::Resource.acquirer_identifier(
|
663
573
|
process_id,
|
664
574
|
thread_id,
|
665
575
|
fiber_id,
|
@@ -674,7 +584,7 @@ class RedisQueuedLocks::Client
|
|
674
584
|
# @option thread_id [Integer,Any] Thread identifier.
|
675
585
|
# @option fiber_id [Integer,Any] Fiber identifier.
|
676
586
|
# @option ractor_id [Integer,Any] Ractor identifier.
|
677
|
-
# @option identity [String] Unique per-process string. See `config[
|
587
|
+
# @option identity [String] Unique per-process string. See `config['uniq_identifier']`.
|
678
588
|
# @return [String]
|
679
589
|
#
|
680
590
|
# @see RedisQueuedLocks::Resource.host_identifier
|
@@ -724,7 +634,7 @@ class RedisQueuedLocks::Client
|
|
724
634
|
# @param lock_name [String]
|
725
635
|
# @param milliseconds [Integer] How many milliseconds should be added.
|
726
636
|
# @option logger [::Logger,#debug]
|
727
|
-
# @option instrumenter [#notify] See `config[
|
637
|
+
# @option instrumenter [#notify] See `config['instrumenter']` docs for details.
|
728
638
|
# @option instrument [NilClass,Any]
|
729
639
|
# @option log_sampling_enabled [Boolean]
|
730
640
|
# @option log_sampling_percent [Integer]
|
@@ -744,19 +654,19 @@ class RedisQueuedLocks::Client
|
|
744
654
|
def extend_lock_ttl(
|
745
655
|
lock_name,
|
746
656
|
milliseconds,
|
747
|
-
logger: config[
|
748
|
-
instrumenter: config[
|
657
|
+
logger: config['logger'], # steep:ignore
|
658
|
+
instrumenter: config['instrumenter'], # steep:ignore
|
749
659
|
instrument: nil,
|
750
|
-
log_sampling_enabled: config[
|
751
|
-
log_sampling_percent: config[
|
752
|
-
log_sampler: config[
|
660
|
+
log_sampling_enabled: config['log_sampling_enabled'], # steep:ignore
|
661
|
+
log_sampling_percent: config['log_sampling_percent'], # steep:ignore
|
662
|
+
log_sampler: config['log_sampler'], # steep:ignore
|
753
663
|
log_sample_this: false,
|
754
|
-
instr_sampling_enabled: config[
|
755
|
-
instr_sampling_percent: config[
|
756
|
-
instr_sampler: config[
|
664
|
+
instr_sampling_enabled: config['instr_sampling_enabled'], # steep:ignore
|
665
|
+
instr_sampling_percent: config['instr_sampling_percent'], # steep:ignore
|
666
|
+
instr_sampler: config['instr_sampler'], # steep:ignore
|
757
667
|
instr_sample_this: false
|
758
668
|
)
|
759
|
-
RedisQueuedLocks::
|
669
|
+
RedisQueuedLocks::Acquirer::ExtendLockTTL.extend_lock_ttl(
|
760
670
|
redis_client,
|
761
671
|
lock_name,
|
762
672
|
milliseconds,
|
@@ -781,7 +691,7 @@ class RedisQueuedLocks::Client
|
|
781
691
|
#
|
782
692
|
# @option batch_size [Integer]
|
783
693
|
# @option logger [::Logger,#debug]
|
784
|
-
# @option instrumenter [#notify] See `config[
|
694
|
+
# @option instrumenter [#notify] See `config['instrumenter']` docs for details.
|
785
695
|
# @option instrument [NilClass,Any]
|
786
696
|
# @option log_sampling_enabled [Boolean]
|
787
697
|
# @option log_sampling_percent [Integer]
|
@@ -791,27 +701,27 @@ class RedisQueuedLocks::Client
|
|
791
701
|
# @option instr_sampling_percent [Integer]
|
792
702
|
# @option instr_sampler [#sampling_happened?,Module<RedisQueuedLocks::Instrument::Sampler>]
|
793
703
|
# @option instr_sample_this [Boolean]
|
794
|
-
# @return [
|
704
|
+
# @return [Hash<Symbol,Boolean|Hash<Symbol,Numeric>>]
|
795
705
|
# Example: { ok: true, result { rel_key_cnt: 100, rel_time: 0.01 } }
|
796
706
|
#
|
797
707
|
# @api public
|
798
708
|
# @since 1.0.0
|
799
709
|
# @version 1.6.0
|
800
710
|
def clear_locks(
|
801
|
-
batch_size: config[
|
802
|
-
logger: config[
|
803
|
-
instrumenter: config[
|
711
|
+
batch_size: config['lock_release_batch_size'], # steep:ignore
|
712
|
+
logger: config['logger'], # steep:ignore
|
713
|
+
instrumenter: config['instrumenter'], # steep:ignore
|
804
714
|
instrument: nil,
|
805
|
-
log_sampling_enabled: config[
|
806
|
-
log_sampling_percent: config[
|
807
|
-
log_sampler: config[
|
715
|
+
log_sampling_enabled: config['log_sampling_enabled'], # steep:ignore
|
716
|
+
log_sampling_percent: config['log_sampling_percent'], # steep:ignore
|
717
|
+
log_sampler: config['log_sampler'], # steep:ignore
|
808
718
|
log_sample_this: false,
|
809
|
-
instr_sampling_enabled: config[
|
810
|
-
instr_sampling_percent: config[
|
811
|
-
instr_sampler: config[
|
719
|
+
instr_sampling_enabled: config['instr_sampling_enabled'], # steep:ignore
|
720
|
+
instr_sampling_percent: config['instr_sampling_percent'], # steep:ignore
|
721
|
+
instr_sampler: config['instr_sampler'], # steep:ignore
|
812
722
|
instr_sample_this: false
|
813
723
|
)
|
814
|
-
RedisQueuedLocks::
|
724
|
+
RedisQueuedLocks::Acquirer::ReleaseAllLocks.release_all_locks(
|
815
725
|
redis_client,
|
816
726
|
batch_size,
|
817
727
|
logger,
|
@@ -848,8 +758,8 @@ class RedisQueuedLocks::Client
|
|
848
758
|
#
|
849
759
|
# @api public
|
850
760
|
# @since 1.0.0
|
851
|
-
def locks(scan_size: config[
|
852
|
-
RedisQueuedLocks::
|
761
|
+
def locks(scan_size: config['key_extraction_batch_size'], with_info: false) # steep:ignore
|
762
|
+
RedisQueuedLocks::Acquirer::Locks.locks(redis_client, scan_size:, with_info:)
|
853
763
|
end
|
854
764
|
|
855
765
|
# Extracts lock keys with their info. See #locks(with_info: true) for details.
|
@@ -859,7 +769,7 @@ class RedisQueuedLocks::Client
|
|
859
769
|
#
|
860
770
|
# @api public
|
861
771
|
# @since 1.0.0
|
862
|
-
def locks_info(scan_size: config[
|
772
|
+
def locks_info(scan_size: config['key_extraction_batch_size']) # steep:ignore
|
863
773
|
locks(scan_size:, with_info: true)
|
864
774
|
end
|
865
775
|
|
@@ -879,8 +789,8 @@ class RedisQueuedLocks::Client
|
|
879
789
|
#
|
880
790
|
# @api public
|
881
791
|
# @since 1.0.0
|
882
|
-
def queues(scan_size: config[
|
883
|
-
RedisQueuedLocks::
|
792
|
+
def queues(scan_size: config['key_extraction_batch_size'], with_info: false) # steep:ignore
|
793
|
+
RedisQueuedLocks::Acquirer::Queues.queues(redis_client, scan_size:, with_info:)
|
884
794
|
end
|
885
795
|
|
886
796
|
# Extracts lock queues with their info. See #queues(with_info: true) for details.
|
@@ -890,7 +800,7 @@ class RedisQueuedLocks::Client
|
|
890
800
|
#
|
891
801
|
# @api public
|
892
802
|
# @since 1.0.0
|
893
|
-
def queues_info(scan_size: config[
|
803
|
+
def queues_info(scan_size: config['key_extraction_batch_size']) # steep:ignore
|
894
804
|
queues(scan_size:, with_info: true)
|
895
805
|
end
|
896
806
|
|
@@ -899,17 +809,17 @@ class RedisQueuedLocks::Client
|
|
899
809
|
#
|
900
810
|
# @api public
|
901
811
|
# @since 1.0.0
|
902
|
-
def keys(scan_size: config[
|
903
|
-
RedisQueuedLocks::
|
812
|
+
def keys(scan_size: config['key_extraction_batch_size']) # steep:ignore
|
813
|
+
RedisQueuedLocks::Acquirer::Keys.keys(redis_client, scan_size:)
|
904
814
|
end
|
905
815
|
|
906
816
|
# @option dead_ttl [Integer]
|
907
817
|
# - the time period (in millsiecnds) after whcih the lock request is
|
908
818
|
# considered as dead;
|
909
|
-
# - `config[
|
819
|
+
# - `config['dead_request_ttl']` is used by default;
|
910
820
|
# @option scan_size [Integer]
|
911
821
|
# - the batch of scanned keys for Redis'es SCAN command;
|
912
|
-
# - `config[
|
822
|
+
# - `config['lock_release_batch_size']` is used by default;
|
913
823
|
# @option logger [::Logger,#debug]
|
914
824
|
# @option instrumenter [#notify]
|
915
825
|
# @option instrument [NilClass,Any]
|
@@ -928,21 +838,21 @@ class RedisQueuedLocks::Client
|
|
928
838
|
# @since 1.0.0
|
929
839
|
# @version 1.6.0
|
930
840
|
def clear_dead_requests(
|
931
|
-
dead_ttl: config[
|
932
|
-
scan_size: config[
|
933
|
-
logger: config[
|
934
|
-
instrumenter: config[
|
841
|
+
dead_ttl: config['dead_request_ttl'], # steep:ignore
|
842
|
+
scan_size: config['lock_release_batch_size'], # steep:ignore
|
843
|
+
logger: config['logger'], # steep:ignore
|
844
|
+
instrumenter: config['instrumenter'], # steep:ignore
|
935
845
|
instrument: nil,
|
936
|
-
log_sampling_enabled: config[
|
937
|
-
log_sampling_percent: config[
|
938
|
-
log_sampler: config[
|
846
|
+
log_sampling_enabled: config['log_sampling_enabled'], # steep:ignore
|
847
|
+
log_sampling_percent: config['log_sampling_percent'], # steep:ignore
|
848
|
+
log_sampler: config['log_sampler'], # steep:ignore
|
939
849
|
log_sample_this: false,
|
940
|
-
instr_sampling_enabled: config[
|
941
|
-
instr_sampling_percent: config[
|
942
|
-
instr_sampler: config[
|
850
|
+
instr_sampling_enabled: config['instr_sampling_enabled'], # steep:ignore
|
851
|
+
instr_sampling_percent: config['instr_sampling_percent'], # steep:ignore
|
852
|
+
instr_sampler: config['instr_sampler'], # steep:ignore
|
943
853
|
instr_sample_this: false
|
944
854
|
)
|
945
|
-
RedisQueuedLocks::
|
855
|
+
RedisQueuedLocks::Acquirer::ClearDeadRequests.clear_dead_requests(
|
946
856
|
redis_client,
|
947
857
|
scan_size,
|
948
858
|
dead_ttl,
|