redis_queued_locks 1.12.1 → 1.14.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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -1
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +45 -5
  5. data/LICENSE.txt +1 -1
  6. data/README.md +574 -296
  7. data/Rakefile +12 -4
  8. data/Steepfile +15 -0
  9. data/github_ci/ruby3.3.gemfile +17 -0
  10. data/github_ci/ruby3.3.gemfile.lock +217 -0
  11. data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/delay_execution.rb +4 -4
  12. data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb +40 -0
  13. data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/dequeue_from_lock_queue.rb +17 -8
  14. data/lib/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rb +166 -0
  15. data/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb +218 -0
  16. data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb +543 -0
  17. data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/try_to_lock.rb +126 -92
  18. data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/with_acq_timeout.rb +14 -9
  19. data/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb +76 -0
  20. data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock/yield_expire.rb +42 -19
  21. data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock.rb +74 -47
  22. data/lib/redis_queued_locks/{acquier → acquirer}/clear_dead_requests.rb +5 -3
  23. data/lib/redis_queued_locks/{acquier → acquirer}/extend_lock_ttl.rb +4 -3
  24. data/lib/redis_queued_locks/{acquier → acquirer}/is_locked.rb +1 -1
  25. data/lib/redis_queued_locks/{acquier → acquirer}/is_queued.rb +1 -1
  26. data/lib/redis_queued_locks/{acquier → acquirer}/keys.rb +5 -5
  27. data/lib/redis_queued_locks/{acquier → acquirer}/lock_info.rb +9 -5
  28. data/lib/redis_queued_locks/{acquier → acquirer}/locks.rb +16 -3
  29. data/lib/redis_queued_locks/{acquier → acquirer}/queue_info.rb +8 -6
  30. data/lib/redis_queued_locks/{acquier → acquirer}/queues.rb +9 -2
  31. data/lib/redis_queued_locks/{acquier → acquirer}/release_all_locks.rb +26 -21
  32. data/lib/redis_queued_locks/{acquier → acquirer}/release_lock.rb +28 -22
  33. data/lib/redis_queued_locks/acquirer/release_locks_of.rb +211 -0
  34. data/lib/redis_queued_locks/acquirer.rb +19 -0
  35. data/lib/redis_queued_locks/client.rb +317 -254
  36. data/lib/redis_queued_locks/config/dsl.rb +94 -0
  37. data/lib/redis_queued_locks/config.rb +236 -0
  38. data/lib/redis_queued_locks/data.rb +2 -0
  39. data/lib/redis_queued_locks/errors.rb +27 -11
  40. data/lib/redis_queued_locks/instrument.rb +11 -4
  41. data/lib/redis_queued_locks/logging/void_logger.rb +38 -1
  42. data/lib/redis_queued_locks/logging.rb +20 -5
  43. data/lib/redis_queued_locks/resource.rb +49 -11
  44. data/lib/redis_queued_locks/swarm/acquirers.rb +17 -16
  45. data/lib/redis_queued_locks/swarm/flush_zombies.rb +26 -25
  46. data/lib/redis_queued_locks/swarm/probe_hosts.rb +20 -19
  47. data/lib/redis_queued_locks/swarm/redis_client_builder.rb +3 -3
  48. data/lib/redis_queued_locks/swarm/supervisor.rb +19 -6
  49. data/lib/redis_queued_locks/swarm/swarm_element/isolated.rb +20 -18
  50. data/lib/redis_queued_locks/swarm/swarm_element/threaded.rb +35 -27
  51. data/lib/redis_queued_locks/swarm/zombie_info.rb +9 -9
  52. data/lib/redis_queued_locks/swarm.rb +20 -41
  53. data/lib/redis_queued_locks/utilities.rb +11 -2
  54. data/lib/redis_queued_locks/version.rb +2 -2
  55. data/lib/redis_queued_locks.rb +2 -3
  56. data/rbs_collection.lock.yaml +28 -0
  57. data/rbs_collection.yaml +17 -0
  58. data/redis_queued_locks.gemspec +22 -23
  59. data/sig/manifest.yml +6 -0
  60. data/sig/redis_queued_locks/acquier.rbs +4 -0
  61. data/sig/redis_queued_locks/acquirer/acquire_lock/delay_execution.rbs +9 -0
  62. data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs +21 -0
  63. data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +26 -0
  64. data/sig/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rbs +71 -0
  65. data/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs +72 -0
  66. data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs +179 -0
  67. data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +48 -0
  68. data/sig/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rbs +19 -0
  69. data/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs +41 -0
  70. data/sig/redis_queued_locks/acquirer/acquire_lock/yield_with_expire/log_visitor.rbs +32 -0
  71. data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +52 -0
  72. data/sig/redis_queued_locks/acquirer/clear_dead_requests.rbs +28 -0
  73. data/sig/redis_queued_locks/acquirer/extend_lock_ttl.rbs +28 -0
  74. data/sig/redis_queued_locks/acquirer/is_locked.rbs +9 -0
  75. data/sig/redis_queued_locks/acquirer/is_queued.rbs +9 -0
  76. data/sig/redis_queued_locks/acquirer/keys.rbs +10 -0
  77. data/sig/redis_queued_locks/acquirer/lock_info.rbs +10 -0
  78. data/sig/redis_queued_locks/acquirer/locks.rbs +16 -0
  79. data/sig/redis_queued_locks/acquirer/queue_info.rbs +13 -0
  80. data/sig/redis_queued_locks/acquirer/queues.rbs +16 -0
  81. data/sig/redis_queued_locks/acquirer/release_all_locks.rbs +30 -0
  82. data/sig/redis_queued_locks/acquirer/release_lock.rbs +38 -0
  83. data/sig/redis_queued_locks/acquirer/release_locks_of.rbs +46 -0
  84. data/sig/redis_queued_locks/client.rbs +235 -0
  85. data/sig/redis_queued_locks/config/dsl.rbs +26 -0
  86. data/sig/redis_queued_locks/config.rbs +23 -0
  87. data/sig/redis_queued_locks/data.rbs +4 -0
  88. data/sig/redis_queued_locks/debugger/interface.rbs +9 -0
  89. data/sig/redis_queued_locks/debugger.rbs +13 -0
  90. data/sig/redis_queued_locks/errors.rbs +43 -0
  91. data/sig/redis_queued_locks/instrument/active_support.rbs +7 -0
  92. data/sig/redis_queued_locks/instrument/sampler.rbs +9 -0
  93. data/sig/redis_queued_locks/instrument/void_notifier.rbs +7 -0
  94. data/sig/redis_queued_locks/instrument.rbs +15 -0
  95. data/sig/redis_queued_locks/logging/sampler.rbs +9 -0
  96. data/sig/redis_queued_locks/logging/void_logger.rbs +15 -0
  97. data/sig/redis_queued_locks/logging.rbs +15 -0
  98. data/sig/redis_queued_locks/resource.rbs +42 -0
  99. data/sig/redis_queued_locks/swarm/acquirers.rbs +10 -0
  100. data/sig/redis_queued_locks/swarm/flush_zombies.rbs +13 -0
  101. data/sig/redis_queued_locks/swarm/probe_hosts.rbs +13 -0
  102. data/sig/redis_queued_locks/swarm/redis_client_builder.rbs +19 -0
  103. data/sig/redis_queued_locks/swarm/supervisor.rbs +26 -0
  104. data/sig/redis_queued_locks/swarm/swarm_element/isolated.rbs +52 -0
  105. data/sig/redis_queued_locks/swarm/swarm_element/threaded.rbs +61 -0
  106. data/sig/redis_queued_locks/swarm/swarm_element.rbs +8 -0
  107. data/sig/redis_queued_locks/swarm/zombie_info.rbs +24 -0
  108. data/sig/redis_queued_locks/swarm.rbs +41 -0
  109. data/sig/redis_queued_locks/utilities/lock.rbs +10 -0
  110. data/sig/redis_queued_locks/utilities.rbs +12 -0
  111. data/sig/redis_queued_locks/version.rbs +3 -0
  112. data/sig/redis_queued_locks.rbs +14 -0
  113. data/sig/vendor/active_support.rbs +9 -0
  114. data/sig/vendor/redis_client.rbs +39 -0
  115. data/sig/vendor/semantic_logger.rbs +4 -0
  116. metadata +98 -54
  117. data/lib/redis_queued_locks/acquier/acquire_lock/dequeue_from_lock_queue/log_visitor.rb +0 -40
  118. data/lib/redis_queued_locks/acquier/acquire_lock/instr_visitor.rb +0 -166
  119. data/lib/redis_queued_locks/acquier/acquire_lock/log_visitor.rb +0 -216
  120. data/lib/redis_queued_locks/acquier/acquire_lock/try_to_lock/log_visitor.rb +0 -541
  121. data/lib/redis_queued_locks/acquier/acquire_lock/yield_expire/log_visitor.rb +0 -76
  122. data/lib/redis_queued_locks/acquier.rb +0 -18
@@ -0,0 +1,30 @@
1
+ use RedisQueuedLocks as RQL
2
+ use RedisClient as RC
3
+
4
+ module RedisQueuedLocks
5
+ module Acquirer
6
+ module ReleaseAllLocks
7
+ extend RQL::Utilities
8
+
9
+ type releaseResult = { ok: bool, result: { rel_key_cnt: Integer, rel_time: Integer|Float } }
10
+ def self.release_all_locks: (
11
+ RC::client redis,
12
+ Integer batch_size,
13
+ RQL::loggerObj logger,
14
+ RQL::instrObj instrumenter,
15
+ untyped instrument,
16
+ bool log_sampling_enabled,
17
+ Integer log_sampling_percent,
18
+ RQL::Logging::samplerObj log_sampler,
19
+ bool log_sample_this,
20
+ bool instr_sampling_enabled,
21
+ Integer instr_sampling_percent,
22
+ RQL::Instrument::samplerObj instr_sampler,
23
+ bool instr_sample_this
24
+ ) -> releaseResult
25
+
26
+ type fullRelesaeResult = { ok: bool, result: { rel_key_cnt: Integer } }
27
+ private def self.fully_release_all_locks: (RC::client redis, Integer batch_size) -> fullRelesaeResult
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ use RedisQueuedLocks as RQL
2
+ use RedisClient as RC
3
+
4
+ module RedisQueuedLocks
5
+ module Acquirer
6
+ module ReleaseLock
7
+ extend RQL::Utilities
8
+
9
+ type releaseResult = {
10
+ ok: bool,
11
+ result: {
12
+ rel_time: Integer|Float,
13
+ rel_key: String,
14
+ rel_queue: String,
15
+ queue_res: Symbol,
16
+ lock_res: Symbol
17
+ }
18
+ }
19
+ def self.release_lock: (
20
+ RC::client redis,
21
+ String lock_name,
22
+ RQL::instrObj instrumenter,
23
+ RQL::loggerObj logger,
24
+ bool log_sampling_enabled,
25
+ Integer log_samplingPercent,
26
+ RQL::Logging::samplerObj log_sampler,
27
+ bool log_sample_this,
28
+ bool instr_sampling_enabled,
29
+ Integer instr_sampling_percent,
30
+ RQL::Instrument::samplerObj instr_sampler,
31
+ bool instr_sample_this
32
+ ) -> releaseResult
33
+
34
+ type fullReleaseResult = { ok: bool, result: { queue: Symbol, lock: Symbol } }
35
+ private def self.fully_release_lock: (RC::client redis, String lock_key, String lock_key_queue) -> fullReleaseResult
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,46 @@
1
+ use RedisQueuedLocks as RQL
2
+ use RedisClient as RC
3
+
4
+ module RedisQueuedLocks
5
+ module Acquirer
6
+ module ReleaseLocksOf
7
+ extend RQL::Utilities
8
+
9
+ type releaseResult = {
10
+ ok: bool,
11
+ result: {
12
+ rel_key_cnt: Integer,
13
+ tch_queue_cnt: Integer,
14
+ rel_time: Integer|Float
15
+ }
16
+ }
17
+ def self.release_locks_of: (
18
+ String host_id,
19
+ String acquirer_id,
20
+ RC::client redis,
21
+ Integer lock_scan_size,
22
+ Integer queue_scan_size,
23
+ RQL::loggerObj logger,
24
+ RQL::instrObj instrumenter,
25
+ untyped instrument,
26
+ bool log_sampling_enabled,
27
+ Integer log_sampling_percent,
28
+ RQL::Logging::samplerObj log_sampler,
29
+ bool log_sample_this,
30
+ bool instr_sampling_enabled,
31
+ Integer instr_sampling_percent,
32
+ RQL::Instrument::samplerObj instr_sampler,
33
+ bool instr_sample_this
34
+ ) -> releaseResult
35
+
36
+ type fullyReleaseAllLocksResult = { ok: bool, result: { rel_key_cnt: Integer, tch_queue_cnt: Integer } }
37
+ private def self.fully_release_locks_of: (
38
+ String refused_host_id,
39
+ String refused_acquirer_id,
40
+ RC::client redis,
41
+ Integer locks_scan_size,
42
+ Integer queue_scan_size
43
+ ) -> fullyReleaseAllLocksResult
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,235 @@
1
+ use RedisQueuedLocks as RQL
2
+ use RedisClient as RC
3
+
4
+ module RedisQueuedLocks
5
+ class Client
6
+ @config: RQL::Config
7
+ @redis_client: RC::client
8
+ @uniq_identity: String
9
+ @swarm: RQL::Swarm
10
+
11
+ attr_reader config: RQL::Config
12
+ attr_reader redis_client: RC::client
13
+ attr_accessor uniq_identity: String
14
+ attr_reader swarm: RQL::Swarm
15
+
16
+ def initialize: (RC::client redis_client) ?{ (RQL::Config) -> void } -> void
17
+ def configure: () ?{ (RQL::Config) -> void } -> void
18
+
19
+ def swarmize!: () -> RQL::Swarm::swarmizeResult
20
+ def deswarmize!: () -> RQL::Swarm::deswarmizeResult
21
+ def swarm_info: (?zombie_ttl: Integer) -> RQL::Swarm::Acquirers::acquirersList
22
+
23
+ def swarm_status: () -> RQL::Swarm::swarmStatus
24
+ alias swarm_state swarm_status
25
+
26
+ def probe_hosts: () -> RQL::Swarm::ProbeHosts::livingHosts
27
+ def flush_zombies: (?zombie_ttl: Integer, ?lock_scan_size: Integer, ?queue_scan_size: Integer) -> RQL::Swarm::FlushZombies::flushedZombies
28
+ def zombie_locks: (?zombie_ttl: Integer, ?lock_scan_size: Integer) -> RQL::Swarm::ZombieInfo::zombieLocks
29
+ def zombie_acquirers: (?zombie_ttl: Integer, ?lock_scan_size: Integer) -> RQL::Swarm::ZombieInfo::zombieAcquirers
30
+ def zombie_hosts: (?zombie_ttl: Integer) -> RQL::Swarm::ZombieInfo::zombieHosts
31
+
32
+ def zombies_info: (?zombie_ttl: Integer, ?lock_scan_size: Integer) -> RQL::Swarm::ZombieInfo::zombieInfo
33
+ alias zombies zombies_info
34
+
35
+ def lock: (
36
+ String lock_name,
37
+ ?ttl: Integer,
38
+ ?queue_ttl: Integer,
39
+ ?timeout: Integer?,
40
+ ?timed: bool,
41
+ ?retry_count: Integer?,
42
+ ?retry_delay: Integer,
43
+ ?retry_jitter: Integer,
44
+ ?raise_errors: bool,
45
+ ?fail_fast: bool,
46
+ ?conflict_strategy: Symbol,
47
+ ?read_write_mode: Symbol,
48
+ ?access_strategy: Symbol,
49
+ ?identity: String,
50
+ ?meta: Hash[String|Symbol,untyped]?,
51
+ ?detailed_acq_timeout_error: bool,
52
+ ?logger: RQL::loggerObj,
53
+ ?log_lock_try: bool,
54
+ ?instrumenter: RQL::instrObj,
55
+ ?instrument: untyped?,
56
+ ?log_sampling_enabled: bool,
57
+ ?log_sampling_percent: Integer,
58
+ ?log_sampler: RQL::Logging::samplerObj,
59
+ ?log_sample_this: bool,
60
+ ?instr_sampling_enabled: bool,
61
+ ?instr_sampling_percent: Integer,
62
+ ?instr_sampler: RQL::Instrument::samplerObj,
63
+ ?instr_sample_this: bool
64
+ ) ?{ (?) -> untyped } -> RQL::Acquirer::AcquireLock::acquireResult
65
+
66
+ def lock!: (
67
+ String lock_name,
68
+ ?ttl: Integer,
69
+ ?queue_ttl: Integer,
70
+ ?timeout: Integer?,
71
+ ?timed: bool,
72
+ ?retry_count: Integer?,
73
+ ?retry_delay: Integer,
74
+ ?retry_jitter: Integer,
75
+ ?fail_fast: bool,
76
+ ?conflict_strategy: Symbol,
77
+ ?read_write_mode: Symbol,
78
+ ?access_strategy: Symbol,
79
+ ?identity: String,
80
+ ?instrumenter: RQL::instrObj,
81
+ ?meta: Hash[String|Symbol,untyped]?,
82
+ ?detailed_acq_timeout_error: bool,
83
+ ?logger: RQL::loggerObj,
84
+ ?log_lock_try: bool,
85
+ ?instrument: untyped?,
86
+ ?log_sampling_enabled: bool,
87
+ ?log_sampling_percent: Integer,
88
+ ?log_sampler: RQL::Logging::samplerObj,
89
+ ?log_sample_this: bool,
90
+ ?instr_sampling_enabled: bool,
91
+ ?instr_sampling_percent: Integer,
92
+ ?instr_sampler: RQL::Instrument::samplerObj,
93
+ ?instr_sample_this: bool,
94
+ ) ?{ (?) -> untyped } -> RQL::Acquirer::AcquireLock::acquireResult
95
+
96
+ def unlock: (
97
+ String lock_name,
98
+ ?logger: RQL::loggerObj,
99
+ ?instrumenter: RQL::instrObj,
100
+ ?instrument: untyped?,
101
+ ?log_sampling_enabled: bool,
102
+ ?log_sampling_percent: Integer,
103
+ ?log_sampler: RQL::Logging::samplerObj,
104
+ ?log_sample_this: bool,
105
+ ?instr_sampling_enabled: bool,
106
+ ?instr_sampling_percent: Integer,
107
+ ?instr_sampler: RQL::Instrument::samplerObj,
108
+ ?instr_sample_this: bool
109
+ ) -> RQL::Acquirer::ReleaseLock::releaseResult
110
+ alias release_lock unlock
111
+
112
+ def locked?: (String lock_name) -> bool
113
+ def queued?: (String lock_name) -> bool
114
+ def lock_info: (String lock_name) -> RQL::Acquirer::LockInfo::lockInfo?
115
+ def queue_info: (String lock_name) -> RQL::Acquirer::QueueInfo::queueInfo?
116
+
117
+ def current_acquirer_id: (
118
+ ?process_id: Integer|String,
119
+ ?thread_id: Integer|String,
120
+ ?fiber_id: Integer|String,
121
+ ?ractor_id: Integer|String,
122
+ ?identity: String
123
+ ) -> String
124
+ alias ccurrent_acq_id current_acquirer_id
125
+ alias acq_id current_acquirer_id
126
+
127
+ def current_host_id: (
128
+ ?process_id: Integer|String,
129
+ ?thread_id: Integer|String,
130
+ ?ractor_id: Integer|String,
131
+ ?identity: String
132
+ ) -> String
133
+ alias current_hst_id current_host_id
134
+ alias hst_id current_host_id
135
+
136
+ def possible_host_ids: (?String identity) -> Array[String]
137
+
138
+ def extend_lock_ttl: (
139
+ String lock_name,
140
+ Integer milliseconds,
141
+ ?logger: RQL::loggerObj,
142
+ ?instrumenter: RQL::instrObj,
143
+ ?instrument: untyped?,
144
+ ?log_sampling_enabled: bool,
145
+ ?log_sampling_percent: Integer,
146
+ ?log_sampler: RQL::Logging::samplerObj,
147
+ ?log_sample_this: bool,
148
+ ?instr_sampling_enabled: bool,
149
+ ?instr_sampling_percent: Integer,
150
+ ?instr_sampler: RQL::Instrument::samplerObj,
151
+ ?instr_sample_this: bool
152
+ ) -> RQL::Acquirer::ExtendLockTTL::extendResult
153
+
154
+ def clear_locks: (
155
+ ?batch_size: Integer,
156
+ ?logger: RQL::loggerObj,
157
+ ?instrumenter: RQL::instrObj,
158
+ ?instrument: untyped?,
159
+ ?log_sampling_enabled: bool,
160
+ ?log_sampling_percent: Integer,
161
+ ?log_sampler: RQL::Logging::samplerObj,
162
+ ?log_sample_this: bool,
163
+ ?instr_sampling_enabled: bool,
164
+ ?instr_sampling_percent: Integer,
165
+ ?instr_sampler: RQL::Instrument::samplerObj,
166
+ ?instr_sample_this: bool
167
+ ) -> RQL::Acquirer::ReleaseAllLocks::releaseResult
168
+ alias release_locks clear_locks
169
+
170
+ def clear_locks_of: (
171
+ host_id: String,
172
+ acquirer_id: String,
173
+ ?lock_scan_size: Integer,
174
+ ?queue_scan_size: Integer,
175
+ ?logger: RQL::loggerObj,
176
+ ?instrumenter: RQL::instrObj,
177
+ ?instrument: untyped?,
178
+ ?log_sampling_enabled: bool,
179
+ ?log_sampling_percent: Integer,
180
+ ?log_sampler: RQL::Logging::samplerObj,
181
+ ?log_sample_this: bool,
182
+ ?instr_sampling_enabled: bool,
183
+ ?instr_sampling_percent: Integer,
184
+ ?instr_sampler: RQL::Instrument::samplerObj,
185
+ ?instr_sample_this: bool
186
+ ) -> RQL::Acquirer::ReleaseLocksOf::releaseResult
187
+ alias release_locks_of clear_locks_of
188
+
189
+ def clear_current_locks: (
190
+ ?lock_scan_size: Integer,
191
+ ?queue_scan_size: Integer,
192
+ ?logger: RQL::loggerObj,
193
+ ?instrumenter: RQL::instrObj,
194
+ ?instrument: untyped?,
195
+ ?log_sampling_enabled: bool,
196
+ ?log_sampling_percent: Integer,
197
+ ?log_sampler: RQL::Logging::samplerObj,
198
+ ?log_sample_this: bool,
199
+ ?instr_sampling_enabled: bool,
200
+ ?instr_sampling_percent: Integer,
201
+ ?instr_sampler: RQL::Instrument::samplerObj,
202
+ ?instr_sample_this: bool
203
+ ) -> RQL::Acquirer::ReleaseLocksOf::releaseResult
204
+ alias release_current_locks clear_current_locks
205
+
206
+ def locks: (?scan_size: Integer, ?with_info: bool) -> RQL::Acquirer::Locks::locks
207
+ | (?scan_size: Integer, ?with_info: true) -> RQL::Acquirer::Locks::locksInfo
208
+ | (?scan_size: Integer, ?with_info: false) -> RQL::Acquirer::Locks::lockList
209
+
210
+ def locks_info: (?scan_size: Integer) -> RQL::Acquirer::Locks::locksInfo
211
+
212
+ def queues: (?scan_size: Integer, ?with_info: bool) -> RQL::Acquirer::Queues::queues
213
+ | (?scan_size: Integer, ?with_info: true) -> RQL::Acquirer::Queues::queuesInfo
214
+ | (?scan_size: Integer, ?with_info: false) -> RQL::Acquirer::Queues::queueList
215
+
216
+ def queues_info: (?scan_size: Integer) -> RQL::Acquirer::Queues::queues
217
+ def keys: (?scan_size: Integer) -> RQL::Acquirer::Keys::keyList
218
+
219
+ def clear_dead_requests: (
220
+ ?dead_ttl: Integer,
221
+ ?scan_size: Integer,
222
+ ?logger: RQL::loggerObj,
223
+ ?instrumenter: RQL::instrObj,
224
+ ?instrument: untyped?,
225
+ ?log_sampling_enabled: bool,
226
+ ?log_sampling_percent: Integer,
227
+ ?log_sampler: RQL::Logging::samplerObj,
228
+ ?log_sample_this: bool,
229
+ ?instr_sampling_enabled: bool,
230
+ ?instr_sampling_percent: Integer,
231
+ ?instr_sampler: RQL::Instrument::samplerObj,
232
+ ?instr_sample_this: bool
233
+ ) -> RQL::Acquirer::ClearDeadRequests::clearResult
234
+ end
235
+ end
@@ -0,0 +1,26 @@
1
+ module RedisQueuedLocks
2
+ class Config
3
+ module DSL
4
+ type configSetters = Hash[String,Proc]
5
+ type configValidators = Hash[String,Proc]
6
+
7
+ module ClassMethods
8
+ @config_setters: configSetters
9
+ @config_validators: configValidators
10
+
11
+ def config_setters: () -> configSetters
12
+ def config_validators: () -> configValidators
13
+
14
+ def validate: (String config_key) { (String) -> bool } -> void
15
+ def setting: (String config_key, untyped config_value) -> void
16
+ end
17
+
18
+ module InstanceMethods
19
+ def config_setters: () -> configSetters
20
+ def config_validators: () -> configValidators
21
+ end
22
+
23
+ def self.included: (Class child_klass) -> void
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ module RedisQueuedLocks
2
+ class Config
3
+ include RedisQueuedLocks::Config::DSL
4
+ include RedisQueuedLocks::Config::DSL::InstanceMethods
5
+ extend RedisQueuedLocks::Config::DSL::ClassMethods
6
+
7
+ type configState = Hash[String,untyped]
8
+
9
+ @config_state: configState
10
+ attr_reader config_state: configState
11
+
12
+ def initialize: () ?{ (RedisQueuedLocks::Config) -> void } -> void
13
+ def configure: () ?{ (RedisQueuedLocks::Config) -> void } -> void
14
+ def []: (String config_key) -> untyped
15
+ def []=: (String config_key, untyped config_value) -> void
16
+ def slice: (String config_key_pattern) -> configState
17
+
18
+ private
19
+
20
+ def prevent_key__non_existent: (String config_key) -> void
21
+ def prevent_key__invalid_type: (String config_key, untyped config_value) -> void
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ module RedisQueuedLocks
2
+ class Data < Hash[untyped,untyped]
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module RedisQueuedLocks
2
+ module Debugger
3
+ module Interface
4
+ def debug: (::String message) -> void
5
+ def enable_debugger!: () -> void
6
+ def disable_debugger!: () -> void
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module RedisQueuedLocks
2
+ module Debugger
3
+ DEBUG_ENABLED_METHOD: String
4
+ DEBUG_DISABLED_MEHTOD: String
5
+
6
+ self.@enabled: bool
7
+
8
+ def self.enable!: () -> void
9
+ def self.disable!: () -> void
10
+ def self.enabled?: () -> bool
11
+ def self.debug: (String message) -> void
12
+ end
13
+ end
@@ -0,0 +1,43 @@
1
+ module RedisQueuedLocks
2
+ class Error < ::StandardError
3
+ end
4
+
5
+ class ArgumentError < ::ArgumentError
6
+ end
7
+
8
+ class LockAlreadyObtainedError < Error
9
+ end
10
+
11
+ class LockAcquirementIntermediateTimeoutError < ::Timeout::Error
12
+ end
13
+
14
+ class LockAcquirementTimeoutError < Error
15
+ end
16
+
17
+ class LockAcquirementRetryLimitError < Error
18
+ end
19
+
20
+ class TimedLockIntermediateTimeoutError < ::Timeout::Error
21
+ end
22
+
23
+ class TimedLockTimeoutError < Error
24
+ end
25
+
26
+ class ConflictLockObtainError < Error
27
+ end
28
+
29
+ class SwarmError < Error
30
+ end
31
+
32
+ class SwarmArgumentError < ArgumentError
33
+ end
34
+
35
+ class ConfigError < Error
36
+ end
37
+
38
+ class ConfigNotFoundError < ConfigError
39
+ end
40
+
41
+ class ConfigValidationError < ConfigError
42
+ end
43
+ end
@@ -0,0 +1,7 @@
1
+ module RedisQueuedLocks
2
+ module Instrument
3
+ module ActiveSupport
4
+ def self.notify: (String event, ?Hash[untyped,untyped] payload) -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module RedisQueuedLocks
2
+ module Instrument
3
+ module Sampler
4
+ SAMPLING_PERCENT_RANGE: Range[Integer]
5
+
6
+ def self.sampling_happened?: (Integer sampling_percent) -> bool
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module RedisQueuedLocks
2
+ module Instrument
3
+ module VoidNotifier
4
+ def self.notify: (String event, ?Hash[untyped,untyped] payload) -> void
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ use RedisQueuedLocks as RQL
2
+
3
+ module RedisQueuedLocks
4
+ module Instrument
5
+ interface _Sampler
6
+ def sampling_happened?: (Integer sampling_percent) -> bool
7
+ end
8
+
9
+ type samplerObj = Object & _Sampler
10
+
11
+ def self.should_instrument?: (bool instr_sampling_enabled, bool instr_sample_this, Integer instr_sampling_percent, samplerObj instr_sampler) -> bool
12
+ def self.valid_sampler?: (untyped sampler) -> bool
13
+ def self.valid_interface?: (untyped instrumenter) -> bool
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module RedisQueuedLocks
2
+ module Logging
3
+ module Sampler
4
+ SAMPLING_PERCENT_RANGE: Range[Integer]
5
+
6
+ def self.sampling_happened?: (Integer sampling_percent) -> bool
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ module RedisQueuedLocks
2
+ module Logging
3
+ module VoidLogger
4
+ def self.warn: (?untyped? progname) { (?) -> untyped } -> nil
5
+ def self.unknown: (?untyped? progname) { (?) -> untyped } -> nil
6
+ def self.log: (?untyped? progname) { (?) -> untyped } -> nil
7
+ def self.info: (?untyped? progname) { (?) -> untyped } -> nil
8
+ def self.error: (?untyped? progname) { (?) -> untyped } -> nil
9
+ def self.fatal: (?untyped? progname) { (?) -> untyped } -> nil
10
+ def self.debug: (?untyped? progname) { (?) -> untyped } -> nil
11
+ def self.add: (?untyped? severity, ?untyped? message, ?untyped? progname) { (?) -> untyped } -> nil
12
+ def self.<<: (untyped message) -> nil
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ use RedisQueuedLocks as RQL
2
+
3
+ module RedisQueuedLocks
4
+ module Logging
5
+ interface _Sampler
6
+ def sampling_happened?: (Integer sampling_percent) -> bool
7
+ end
8
+
9
+ type samplerObj = Object & _Sampler
10
+
11
+ def self.should_log?: (bool log_sampling_enabled, bool log_sample_this, Integer log_sampling_percent, samplerObj log_sampler) -> bool
12
+ def self.valid_sampler?: (untyped sampler) -> bool
13
+ def self.valid_interface?: (untyped logger) -> bool
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ module RedisQueuedLocks
2
+ module Resource
3
+ KEY_PATTERN: String
4
+ LOCK_PATTERN: String
5
+ LOCK_QUEUE_PATTERN: String
6
+ READ_LOCK_QUEUE_PATTERN: String
7
+ WRITE_LOCK_QUEUE_PATTERN: String
8
+ SWARM_KEY: String
9
+ REDIS_TIMESHIFT_ERROR: Integer
10
+
11
+ def self.calc_uniq_identity: () -> String
12
+ def self.acquirer_identifier: (
13
+ Integer|String process_id,
14
+ Integer|String thread_id,
15
+ Integer|String fiber_id,
16
+ Integer|String ractor_id,
17
+ String identity
18
+ ) -> String
19
+
20
+ def self.host_identifier: (
21
+ Integer|String process_id,
22
+ Integer|String thread_id,
23
+ Integer|string ractor_id,
24
+ String identity
25
+ ) -> String
26
+
27
+ def self.prepare_lock_key: (String lock_name) -> String
28
+ def self.prepare_lock_queue: (String lock_name) -> String
29
+ def self.prepare_read_lock_queue: (String lock_name) -> String
30
+ def self.prepare_write_lock_queue: (String lock_name) -> String
31
+ def self.calc_initial_acquirer_position: () -> Float
32
+ def self.acquirer_dead_score: (Integer|Float queue_ttl) -> Float
33
+ def self.calc_zombie_score: (Float zombie_ttl) -> Float
34
+ def self.dead_score_reached?: (Float acquirer_position, Integer queue_ttl) -> bool
35
+ def self.lock_key_from_queue: (String lock_queue) -> String
36
+ def self.get_thread_id: () -> Integer
37
+ def self.get_fiber_id: () -> Integer
38
+ def self.get_ractor_id: () -> Integer
39
+ def self.get_process_id: () -> Integer
40
+ def self.possible_host_identifiers: (String identity) -> Array[String]
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ use RedisClient as RC
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ module Acquirers
6
+ type acquirersList = Hash[String,{ zombie: bool, last_probe_time: Time, last_probe_score: Float }]
7
+ def self.acquirers: (RC::client redis_client, Integer zombie_ttl) -> acquirersList
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ use RedisClient as RC
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ class FlushZombies < SwarmElement::Isolated
6
+ type flushedZombies = { ok: bool, deleted_zombie_hosts: Set[String], deleted_zombie_acquirers: Set[String], deleted_zombie_locks: Set[String] }
7
+ def self.flush_zombies: (RC::client redis_client, Integer zombie_ttl, Integer lock_scan_size, Integer queue_scan_size) -> flushedZombies
8
+
9
+ def enabled?: () -> bool
10
+ def swarm!: () -> void
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ use RedisClient as RC
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ class ProbeHosts < SwarmElement::Threaded
6
+ type livingHosts = { ok: bool, result: Hash[String,Float] }
7
+ def self.probe_hosts: (RC::client redis_client, String uniq_identity) -> livingHosts
8
+
9
+ def enabled?: () -> bool
10
+ def spawn_main_loop!: () -> Thread
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ use RedisClient as RC
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ module RedisClientBuilder
6
+ def self.build: (
7
+ ?pooled: bool,
8
+ ?sentinel: bool,
9
+ ?config: Hash[untyped,untyped],
10
+ ?pool_config: Hash[untyped,untyped]
11
+ ) -> RC::client
12
+
13
+ private def self.sentinel_config: (Hash[Symbol,untyped] config) -> RC::SentinelConfig
14
+ private def self.non_sentinel_config: (Hash[Symbol,untyped] config) -> RC::Config
15
+ private def self.pooled_client: (RC::config redis_config, Hash[Symbol,untyped] pool_config) -> RedisClient::Pooled
16
+ private def self.non_pooled_client: (RC::config redis_config) -> RedisClient
17
+ end
18
+ end
19
+ end