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.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +42 -5
  5. data/LICENSE.txt +1 -1
  6. data/README.md +231 -203
  7. data/Rakefile +12 -4
  8. data/Steepfile +16 -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 -13
  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 +43 -20
  21. data/lib/redis_queued_locks/{acquier → acquirer}/acquire_lock.rb +69 -42
  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 +23 -18
  32. data/lib/redis_queued_locks/{acquier → acquirer}/release_lock.rb +25 -19
  33. data/lib/redis_queued_locks/acquirer.rb +18 -0
  34. data/lib/redis_queued_locks/client.rb +164 -254
  35. data/lib/redis_queued_locks/config/dsl.rb +94 -0
  36. data/lib/redis_queued_locks/config.rb +231 -0
  37. data/lib/redis_queued_locks/data.rb +2 -0
  38. data/lib/redis_queued_locks/errors.rb +27 -11
  39. data/lib/redis_queued_locks/instrument.rb +11 -4
  40. data/lib/redis_queued_locks/logging/void_logger.rb +38 -1
  41. data/lib/redis_queued_locks/logging.rb +20 -5
  42. data/lib/redis_queued_locks/resource.rb +49 -11
  43. data/lib/redis_queued_locks/swarm/acquirers.rb +17 -16
  44. data/lib/redis_queued_locks/swarm/flush_zombies.rb +26 -25
  45. data/lib/redis_queued_locks/swarm/probe_hosts.rb +20 -19
  46. data/lib/redis_queued_locks/swarm/redis_client_builder.rb +3 -3
  47. data/lib/redis_queued_locks/swarm/supervisor.rb +19 -6
  48. data/lib/redis_queued_locks/swarm/swarm_element/isolated.rb +20 -18
  49. data/lib/redis_queued_locks/swarm/swarm_element/threaded.rb +35 -27
  50. data/lib/redis_queued_locks/swarm/zombie_info.rb +9 -9
  51. data/lib/redis_queued_locks/swarm.rb +20 -41
  52. data/lib/redis_queued_locks/utilities/lock.rb +4 -2
  53. data/lib/redis_queued_locks/utilities.rb +2 -2
  54. data/lib/redis_queued_locks/version.rb +2 -2
  55. data/lib/redis_queued_locks.rb +2 -2
  56. data/rbs_collection.lock.yaml +40 -0
  57. data/rbs_collection.yaml +16 -0
  58. data/redis_queued_locks.gemspec +22 -23
  59. data/sig/manifest.yml +7 -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 +51 -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/client.rbs +195 -0
  84. data/sig/redis_queued_locks/config/dsl.rbs +26 -0
  85. data/sig/redis_queued_locks/config.rbs +23 -0
  86. data/sig/redis_queued_locks/data.rbs +4 -0
  87. data/sig/redis_queued_locks/debugger/interface.rbs +9 -0
  88. data/sig/redis_queued_locks/debugger.rbs +13 -0
  89. data/sig/redis_queued_locks/errors.rbs +43 -0
  90. data/sig/redis_queued_locks/instrument/active_support.rbs +7 -0
  91. data/sig/redis_queued_locks/instrument/sampler.rbs +9 -0
  92. data/sig/redis_queued_locks/instrument/void_notifier.rbs +7 -0
  93. data/sig/redis_queued_locks/instrument.rbs +15 -0
  94. data/sig/redis_queued_locks/logging/sampler.rbs +9 -0
  95. data/sig/redis_queued_locks/logging/void_logger.rbs +15 -0
  96. data/sig/redis_queued_locks/logging.rbs +15 -0
  97. data/sig/redis_queued_locks/resource.rbs +42 -0
  98. data/sig/redis_queued_locks/swarm/acquirers.rbs +10 -0
  99. data/sig/redis_queued_locks/swarm/flush_zombies.rbs +13 -0
  100. data/sig/redis_queued_locks/swarm/probe_hosts.rbs +13 -0
  101. data/sig/redis_queued_locks/swarm/redis_client_builder.rbs +19 -0
  102. data/sig/redis_queued_locks/swarm/supervisor.rbs +26 -0
  103. data/sig/redis_queued_locks/swarm/swarm_element/isolated.rbs +52 -0
  104. data/sig/redis_queued_locks/swarm/swarm_element/threaded.rbs +61 -0
  105. data/sig/redis_queued_locks/swarm/swarm_element.rbs +8 -0
  106. data/sig/redis_queued_locks/swarm/zombie_info.rbs +24 -0
  107. data/sig/redis_queued_locks/swarm.rbs +41 -0
  108. data/sig/redis_queued_locks/utilities/lock.rbs +10 -0
  109. data/sig/redis_queued_locks/utilities.rbs +11 -0
  110. data/sig/redis_queued_locks/version.rbs +3 -0
  111. data/sig/redis_queued_locks.rbs +14 -0
  112. data/sig/vendor/active_support.rbs +9 -0
  113. data/sig/vendor/redis_client.rbs +39 -0
  114. data/sig/vendor/semantic_logger.rbs +4 -0
  115. metadata +96 -54
  116. data/lib/redis_queued_locks/acquier/acquire_lock/dequeue_from_lock_queue/log_visitor.rb +0 -40
  117. data/lib/redis_queued_locks/acquier/acquire_lock/instr_visitor.rb +0 -166
  118. data/lib/redis_queued_locks/acquier/acquire_lock/log_visitor.rb +0 -216
  119. data/lib/redis_queued_locks/acquier/acquire_lock/try_to_lock/log_visitor.rb +0 -541
  120. data/lib/redis_queued_locks/acquier/acquire_lock/yield_expire/log_visitor.rb +0 -76
  121. 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,195 @@
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
+
125
+ def current_host_id: (
126
+ ?process_id: Integer|String,
127
+ ?thread_id: Integer|String,
128
+ ?ractor_id: Integer|String,
129
+ ?identity: String
130
+ ) -> String
131
+
132
+ def possible_host_ids: (?String identity) -> Array[String]
133
+
134
+ def extend_lock_ttl: (
135
+ String lock_name,
136
+ Integer milliseconds,
137
+ ?logger: RQL::loggerObj,
138
+ ?instrumenter: RQL::instrObj,
139
+ ?instrument: untyped?,
140
+ ?log_sampling_enabled: bool,
141
+ ?log_sampling_percent: Integer,
142
+ ?log_sampler: RQL::Logging::samplerObj,
143
+ ?log_sample_this: bool,
144
+ ?instr_sampling_enabled: bool,
145
+ ?instr_sampling_percent: Integer,
146
+ ?instr_sampler: RQL::Instrument::samplerObj,
147
+ ?instr_sample_this: bool
148
+ ) -> RQL::Acquirer::ExtendLockTTL::extendResult
149
+
150
+ def clear_locks: (
151
+ ?batch_size: Integer,
152
+ ?logger: RQL::loggerObj,
153
+ ?instrumenter: RQL::instrObj,
154
+ ?instrument: untyped?,
155
+ ?log_sampling_enabled: bool,
156
+ ?log_sampling_percent: Integer,
157
+ ?log_sampler: RQL::Logging::samplerObj,
158
+ ?log_sample_this: bool,
159
+ ?instr_sampling_enabled: bool,
160
+ ?instr_sampling_percent: Integer,
161
+ ?instr_sampler: RQL::Instrument::samplerObj,
162
+ ?instr_sample_this: bool
163
+ ) -> RQL::Acquirer::ReleaseAllLocks::releaseResult
164
+ alias release_locks clear_locks
165
+
166
+ def locks: (?scan_size: Integer, ?with_info: bool) -> RQL::Acquirer::Locks::locks
167
+ | (?scan_size: Integer, ?with_info: true) -> RQL::Acquirer::Locks::locksInfo
168
+ | (?scan_size: Integer, ?with_info: false) -> RQL::Acquirer::Locks::lockList
169
+
170
+ def locks_info: (?scan_size: Integer) -> RQL::Acquirer::Locks::locksInfo
171
+
172
+ def queues: (?scan_size: Integer, ?with_info: bool) -> RQL::Acquirer::Queues::queues
173
+ | (?scan_size: Integer, ?with_info: true) -> RQL::Acquirer::Queues::queuesInfo
174
+ | (?scan_size: Integer, ?with_info: false) -> RQL::Acquirer::Queues::queueList
175
+
176
+ def queues_info: (?scan_size: Integer) -> RQL::Acquirer::Queues::queues
177
+ def keys: (?scan_size: Integer) -> RQL::Acquirer::Keys::keyList
178
+
179
+ def clear_dead_requests: (
180
+ ?dead_ttl: Integer,
181
+ ?scan_size: Integer,
182
+ ?logger: RQL::loggerObj,
183
+ ?instrumenter: RQL::instrObj,
184
+ ?instrument: untyped?,
185
+ ?log_sampling_enabled: bool,
186
+ ?log_sampling_percent: Integer,
187
+ ?log_sampler: RQL::Logging::samplerObj,
188
+ ?log_sample_this: bool,
189
+ ?instr_sampling_enabled: bool,
190
+ ?instr_sampling_percent: Integer,
191
+ ?instr_sampler: RQL::Instrument::samplerObj,
192
+ ?instr_sample_this: bool
193
+ ) -> RQL::Acquirer::ClearDeadRequests::clearResult
194
+ end
195
+ 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
@@ -0,0 +1,26 @@
1
+ use RedisQueuedLocks as RQL
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ class Supervisor
6
+ include RQL::Utilities
7
+
8
+ @rql_client: RQL::Client
9
+ @visor: Thread?
10
+ @observable: Proc?
11
+
12
+ attr_reader rql_client: RQL::Client
13
+ attr_reader visor: Thread?
14
+ attr_reader observable: Proc?
15
+
16
+ def initialize: (RQL::Client rql_client) -> void
17
+
18
+ type supervisorStatus = { running: bool, state: String, observable: String }
19
+ def status: () -> supervisorStatus
20
+
21
+ def observe!: () { (?) -> untyped } -> void
22
+ def running?: () -> bool
23
+ def stop!: () -> void
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,52 @@
1
+ use RedisQueuedLocks as RQL
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ module SwarmElement
6
+ class Isolated
7
+ include RQL::Utilities
8
+
9
+ @rql_client: RQL::Client
10
+ @swarm_element: Ractor?
11
+ @sync: RQL::Utilities::Lock
12
+
13
+ attr_reader rql_client: RQL::Client
14
+ attr_reader swarm_element: Ractor?
15
+ attr_reader sync: RQL::Utilities::Lock
16
+
17
+ def initialize: (RQL::Client rql_client) -> void
18
+ def try_swarm!: () -> void
19
+ def reswarm_if_dead!: () -> void
20
+ def try_kill!: () -> void
21
+ def enabled?: () -> bool
22
+
23
+ type elementStatus = {
24
+ enabled: bool,
25
+ ractor: { running: bool, state: String },
26
+ main_loop: { running: bool, state: String }
27
+ }
28
+ def status: () -> elementStatus
29
+
30
+ def self.swarm_loop: () { () -> Thread } -> void
31
+
32
+ private
33
+
34
+ def swarm!: () -> void
35
+ def idle?: () -> bool
36
+ def swarmed?: () -> bool
37
+ def swarmed__alive?: () -> bool
38
+ def swarmed__dead?: () -> bool
39
+ def swarmed__running?: () -> bool
40
+ def swarmed__stopped?: () -> bool
41
+ def swarm_loop__is_active: () -> bool
42
+
43
+ type swarmLoopStatus = { main_loop: { alive: bool, state: String } }
44
+ def swarm_loop__status: () -> swarmLoopStatus?
45
+
46
+ def swarm_loop__start: () -> void
47
+ def swarm_loop__pause: () -> void
48
+ def swarm_loop__kill: () -> void
49
+ end
50
+ end
51
+ end
52
+ end