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,61 @@
1
+ use RedisQueuedLocks as RQL
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ module SwarmElement
6
+ class Threaded
7
+ include RQL::Utilities
8
+
9
+ @rql_client: RQL::Client
10
+ @swarm_element: Thread?
11
+ @main_loop: Thread?
12
+ @swarm_element_commands: Thread::SizedQueue[Symbol]?
13
+ @swarm_element_results: Thread::SizedQueue[{ ok: bool, result: Hash[untyped,untyped] }]?
14
+ @sync: RQL::Utilities::Lock
15
+
16
+ attr_reader rql_client: RQL::Client
17
+ attr_reader swarm_element: Thread?
18
+ attr_reader main_loop: Thread?
19
+ attr_reader swarm_element_commands: Thread::SizedQueue[Symbol]?
20
+ attr_reader swarm_element_results: Thread::SizedQueue[{ ok: bool, result: Hash[untyped,untyped] }]?
21
+ attr_reader sync: RQL::Utilities::Lock
22
+
23
+ def initialize: (RQL::Client rql_client) -> void
24
+
25
+ def try_swarm!: () -> void
26
+ def reswarm_if_dead!: () -> void
27
+ def try_kill!: () -> void
28
+ def enabled?: () -> bool
29
+
30
+ type elementStatus = {
31
+ enabled: bool,
32
+ thread: { running: bool, state: String },
33
+ main_loop: { running: bool, state: String }
34
+ }
35
+ def status: () -> elementStatus
36
+
37
+ private
38
+
39
+ def swarm!: () -> void
40
+ def spawn_main_loop!: () -> Thread
41
+ def idle?: () -> bool
42
+ def swarmed?: () -> bool
43
+ def swarmed__alive?: () -> bool
44
+ def swarmed__dead?: () -> bool
45
+ def swarmed__running?: () -> bool
46
+ def terminating?: () -> bool?
47
+ def swarmed__stopped?: () -> bool
48
+
49
+ type swarmLoopIsActive = { ok: bool, result: { is_active: bool } }
50
+ def swarm_loop__is_active: () -> swarmLoopIsActive?
51
+
52
+ type swarmLoopStatus = { ok: bool, result: { main_loop: { alive: bool, state: String } } }
53
+ def swarm_loop__status: () -> swarmLoopStatus?
54
+
55
+ def swarm_loop__start: () -> void
56
+ def swarm_loop__stop: () -> void
57
+ def swarm_element__termiante: () -> void
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ module SwarmElement
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ use RedisClient as RC
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ module ZombieInfo
6
+ type zombieInfo = { zombie_hosts: Set[String], zombie_acquirers: Set[String], zombie_locks: Set[String] }
7
+ def self.zombies_info: (RC::client redis_client, Integer zombie_ttl, Integer lock_scan_size) -> zombieInfo
8
+
9
+ type zombieLocks = Set[String]
10
+ def self.zombie_locks: (RC::client redis_client, Integer zombie_ttl, Integer lock_scan_size) -> zombieLocks
11
+
12
+ type zombieHosts = Set[String]
13
+ def self.zombie_hosts: (RC::client redis_client, Integer zombie_ttl) -> zombieHosts
14
+
15
+ type zombieAcquirers = Set[String]
16
+ def self.zombie_acquirers: (RC::client redis_client, Integer zombie_ttl, Integer lock_scan_size) -> zombieAcquirers
17
+
18
+ private def self.extract_zombie_hosts: (RC::client rconn, Integer zombie_ttl) -> zombieHosts
19
+ private def self.extract_zombie_locks: (RC::client rconn, Integer zombie_ttl, Integer lock_scan_size) -> zombieLocks
20
+ private def self.extract_zombie_acquirers: (RC::client rconn, Integer zombie_ttl, Integer lock_scan_size) -> zombieAcquirers
21
+ private def self.extract_all: (RC::client rconn, Integer zombie_ttl, Integer lock_scan_size) -> zombieInfo
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,41 @@
1
+ use RedisQueuedLocks as RQL
2
+
3
+ module RedisQueuedLocks
4
+ class Swarm
5
+ @rql_client: RQL::Client
6
+ @supervisor: RQL::Swarm::Supervisor
7
+ @probe_hosts_element: RQL::Swarm::ProbeHosts
8
+ @flush_zombies_element: RQL::Swarm::FlushZombies
9
+ @sync: RQL::Utilities::Lock
10
+
11
+ attr_reader rql_client: RQL::Client
12
+ attr_reader supervisor: RQL::Swarm::Supervisor
13
+ attr_reader probe_hosts_element: RQL::Swarm::ProbeHosts
14
+ attr_reader flush_zombies_element: RQL::Swarm::FlushZombies
15
+ attr_reader sync: RQL::Utilities::Lock
16
+
17
+ def initialize: (RQL::Client rql_client) -> void
18
+
19
+ type swarmStatus = {
20
+ auto_swarm: bool,
21
+ supervisor: RQL::Swarm::Supervisor::supervisorStatus,
22
+ probe_hosts: RQL::Swarm::SwarmElement::Threaded::elementStatus,
23
+ flush_zombies: RQL::Swarm::SwarmElement::Isolated::elementStatus
24
+ }
25
+ def swarm_status: () -> swarmStatus
26
+
27
+ def swarm_info: (?zombie_ttl: Integer) -> RQL::Swarm::Acquirers::acquirersList
28
+ def probe_hosts: () -> RQL::Swarm::ProbeHosts::livingHosts
29
+ def flush_zombies: (?zombie_ttl: Integer, ?lock_scan_size: Integer, ?queue_scan_size: Integer) -> RQL::Swarm::FlushZombies::flushedZombies
30
+ def zombie_locks: (?zombie_ttl: Integer, ?lock_scan_size: Integer) -> RQL::Swarm::ZombieInfo::zombieLocks
31
+ def zombie_acquirers: (?zombie_ttl: Integer, ?lock_scan_size: Integer) -> RQL::Swarm::ZombieInfo::zombieAcquirers
32
+ def zombie_hosts: (?zombie_ttl: Integer) -> RQL::Swarm::ZombieInfo::zombieHosts
33
+ def zombies_info: (?zombie_ttl: Integer, ?lock_scan_size: Integer) -> RQL::Swarm::ZombieInfo::zombieInfo
34
+
35
+ type swarmizeResult = { ok: bool, result: Symbol }
36
+ def swarm!: () -> swarmizeResult
37
+
38
+ type deswarmizeResult = { ok: bool, result: Symbol }
39
+ def deswarm!: () -> deswarmizeResult
40
+ end
41
+ end
@@ -0,0 +1,10 @@
1
+ module RedisQueuedLocks
2
+ module Utilities
3
+ class Lock
4
+ @lock: Monitor
5
+
6
+ def initialize: () -> void
7
+ def synchronize: () { (?) -> untyped } -> untyped
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ module RedisQueuedLocks
2
+ module Utilities
3
+ RACTOR_LIVENESS_PATTERN: Regexp
4
+ RACTOR_STATUS_PATTERN: Regexp
5
+
6
+ def self?.run_non_critical: () { (?) -> untyped } -> untyped?
7
+ def self?.ractor_status: (Ractor ractor) -> String
8
+ def self?.ractor_alive?: (Ractor ractor) -> bool
9
+ def self?.thread_state: (Thread thread) -> String
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module RedisQueuedLocks
2
+ VERSION: String
3
+ end
@@ -0,0 +1,14 @@
1
+ module RedisQueuedLocks
2
+ interface _Loggable
3
+ def debug: (?untyped? progname) { (?) -> untyped } -> untyped
4
+ end
5
+
6
+ interface _Instrumentable
7
+ def notify: (String event, ?Hash[untyped,untyped] payload) -> void
8
+ end
9
+
10
+ type loggerObj = Object & _Loggable
11
+ type instrObj = Object & _Instrumentable
12
+
13
+ extend ::RedisQueuedLocks::Debugger::Interface
14
+ end
@@ -0,0 +1,9 @@
1
+ module ActiveSupport
2
+ module Notifications
3
+ def self.instrument: (String event, Hash[untyped,untyped] payload) -> untyped
4
+ end
5
+
6
+ class BroadcastLogger
7
+ def debug: (*untyped, **untyped) { (?) -> untyped } -> untyped
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ class RedisClient
2
+ interface _Client
3
+ def call: (*untyped) -> untyped
4
+ def pipelined: () { (Pipeline pipeline) -> untyped } -> untyped
5
+ def scan: (*untyped) { (String key) -> untyped } -> untyped
6
+ def multi: (?watch: Array[String]) { (Multi transact) -> untyped } -> untyped
7
+ def with: (?untyped) { (::RedisClient|::RedisClient::Pooled rconn) -> untyped } -> untyped
8
+ end
9
+
10
+ include _Client
11
+
12
+ class Pooled
13
+ include _Client
14
+ end
15
+
16
+ class Pipeline
17
+ def call: (*untyped) -> untyped
18
+ end
19
+
20
+ class Multi
21
+ def call: (*untyped) -> untyped
22
+ end
23
+
24
+ class SentinelConfig
25
+ def new_pool: (**untyped) -> ::RedisClient::Pooled
26
+ def new_client: (**untyped) -> ::RedisClient
27
+ end
28
+
29
+ class Config
30
+ def new_pool: (**untyped) -> ::RedisClient::Pooled
31
+ def new_client: (**untyped) -> ::RedisClient
32
+ end
33
+
34
+ def self.sentinel: (**untyped) -> SentinelConfig
35
+ def self.config: (**untyped) -> Config
36
+
37
+ type client = ::RedisClient | ::RedisClient::Pooled
38
+ type config = ::RedisClient::Config | ::RedisClient::SentinelConfig
39
+ end
@@ -0,0 +1,4 @@
1
+ module SemanticLogger
2
+ class Logger
3
+ end
4
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_queued_locks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-08-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: redis-client
@@ -24,30 +23,12 @@ dependencies:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0.20'
27
- - !ruby/object:Gem::Dependency
28
- name: qonfig
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.28'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.28'
41
- description: '|> Distributed locks with "prioritized lock acquisition queue" capabilities
42
- based on the Redis Database. |> Each lock request is put into the request queue
43
- (each lock is hosted by it''s own queue separately from other queues) and processed
44
- in order of their priority (FIFO). |> Each lock request lives some period of time
45
- (RTTL) (with requeue capabilities) which guarantees the request queue will never
46
- be stacked. |> In addition to the classic `queued` (FIFO) strategy RQL supports
47
- `random` (RANDOM) lock obtaining strategy when any acquirer from the lock queue
48
- can obtain the lock regardless the position in the queue. |> Provides flexible invocation
49
- flow, parametrized limits (lock request ttl, lock ttl, queue ttl, lock attempts
50
- limit, fast failing, etc), logging and instrumentation.'
26
+ description: |-
27
+ |> Distributed locks with "prioritized lock acquisition queue" capabilities based on the Redis Database.
28
+ |> Each lock request is put into the request queue (each lock is hosted by it's own queue separately from other queues) and processed in order of their priority (FIFO).
29
+ |> Each lock request lives some period of time (RTTL) (with requeue capabilities) which guarantees the request queue will never be stacked.
30
+ |> In addition to the classic `queued` (FIFO) strategy RQL supports `random` (RANDOM) lock obtaining strategy when any acquirer from the lock queue can obtain the lock regardless the position in the queue.
31
+ |> Provides flexible invocation flow, parametrized limits (lock request ttl, lock ttl, queue ttl, lock attempts limit, fast failing, etc), logging and instrumentation.
51
32
  email:
52
33
  - iamdaiver@gmail.com
53
34
  executables: []
@@ -62,31 +43,36 @@ files:
62
43
  - LICENSE.txt
63
44
  - README.md
64
45
  - Rakefile
46
+ - Steepfile
47
+ - github_ci/ruby3.3.gemfile
48
+ - github_ci/ruby3.3.gemfile.lock
65
49
  - lib/redis_queued_locks.rb
66
- - lib/redis_queued_locks/acquier.rb
67
- - lib/redis_queued_locks/acquier/acquire_lock.rb
68
- - lib/redis_queued_locks/acquier/acquire_lock/delay_execution.rb
69
- - lib/redis_queued_locks/acquier/acquire_lock/dequeue_from_lock_queue.rb
70
- - lib/redis_queued_locks/acquier/acquire_lock/dequeue_from_lock_queue/log_visitor.rb
71
- - lib/redis_queued_locks/acquier/acquire_lock/instr_visitor.rb
72
- - lib/redis_queued_locks/acquier/acquire_lock/log_visitor.rb
73
- - lib/redis_queued_locks/acquier/acquire_lock/try_to_lock.rb
74
- - lib/redis_queued_locks/acquier/acquire_lock/try_to_lock/log_visitor.rb
75
- - lib/redis_queued_locks/acquier/acquire_lock/with_acq_timeout.rb
76
- - lib/redis_queued_locks/acquier/acquire_lock/yield_expire.rb
77
- - lib/redis_queued_locks/acquier/acquire_lock/yield_expire/log_visitor.rb
78
- - lib/redis_queued_locks/acquier/clear_dead_requests.rb
79
- - lib/redis_queued_locks/acquier/extend_lock_ttl.rb
80
- - lib/redis_queued_locks/acquier/is_locked.rb
81
- - lib/redis_queued_locks/acquier/is_queued.rb
82
- - lib/redis_queued_locks/acquier/keys.rb
83
- - lib/redis_queued_locks/acquier/lock_info.rb
84
- - lib/redis_queued_locks/acquier/locks.rb
85
- - lib/redis_queued_locks/acquier/queue_info.rb
86
- - lib/redis_queued_locks/acquier/queues.rb
87
- - lib/redis_queued_locks/acquier/release_all_locks.rb
88
- - lib/redis_queued_locks/acquier/release_lock.rb
50
+ - lib/redis_queued_locks/acquirer.rb
51
+ - lib/redis_queued_locks/acquirer/acquire_lock.rb
52
+ - lib/redis_queued_locks/acquirer/acquire_lock/delay_execution.rb
53
+ - lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb
54
+ - lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb
55
+ - lib/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rb
56
+ - lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb
57
+ - lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb
58
+ - lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb
59
+ - lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb
60
+ - lib/redis_queued_locks/acquirer/acquire_lock/yield_expire.rb
61
+ - lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb
62
+ - lib/redis_queued_locks/acquirer/clear_dead_requests.rb
63
+ - lib/redis_queued_locks/acquirer/extend_lock_ttl.rb
64
+ - lib/redis_queued_locks/acquirer/is_locked.rb
65
+ - lib/redis_queued_locks/acquirer/is_queued.rb
66
+ - lib/redis_queued_locks/acquirer/keys.rb
67
+ - lib/redis_queued_locks/acquirer/lock_info.rb
68
+ - lib/redis_queued_locks/acquirer/locks.rb
69
+ - lib/redis_queued_locks/acquirer/queue_info.rb
70
+ - lib/redis_queued_locks/acquirer/queues.rb
71
+ - lib/redis_queued_locks/acquirer/release_all_locks.rb
72
+ - lib/redis_queued_locks/acquirer/release_lock.rb
89
73
  - lib/redis_queued_locks/client.rb
74
+ - lib/redis_queued_locks/config.rb
75
+ - lib/redis_queued_locks/config/dsl.rb
90
76
  - lib/redis_queued_locks/data.rb
91
77
  - lib/redis_queued_locks/debugger.rb
92
78
  - lib/redis_queued_locks/debugger/interface.rb
@@ -112,7 +98,65 @@ files:
112
98
  - lib/redis_queued_locks/utilities.rb
113
99
  - lib/redis_queued_locks/utilities/lock.rb
114
100
  - lib/redis_queued_locks/version.rb
101
+ - rbs_collection.lock.yaml
102
+ - rbs_collection.yaml
115
103
  - redis_queued_locks.gemspec
104
+ - sig/manifest.yml
105
+ - sig/redis_queued_locks.rbs
106
+ - sig/redis_queued_locks/acquier.rbs
107
+ - sig/redis_queued_locks/acquirer/acquire_lock.rbs
108
+ - sig/redis_queued_locks/acquirer/acquire_lock/delay_execution.rbs
109
+ - sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs
110
+ - sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs
111
+ - sig/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rbs
112
+ - sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs
113
+ - sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs
114
+ - sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs
115
+ - sig/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rbs
116
+ - sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs
117
+ - sig/redis_queued_locks/acquirer/acquire_lock/yield_with_expire/log_visitor.rbs
118
+ - sig/redis_queued_locks/acquirer/clear_dead_requests.rbs
119
+ - sig/redis_queued_locks/acquirer/extend_lock_ttl.rbs
120
+ - sig/redis_queued_locks/acquirer/is_locked.rbs
121
+ - sig/redis_queued_locks/acquirer/is_queued.rbs
122
+ - sig/redis_queued_locks/acquirer/keys.rbs
123
+ - sig/redis_queued_locks/acquirer/lock_info.rbs
124
+ - sig/redis_queued_locks/acquirer/locks.rbs
125
+ - sig/redis_queued_locks/acquirer/queue_info.rbs
126
+ - sig/redis_queued_locks/acquirer/queues.rbs
127
+ - sig/redis_queued_locks/acquirer/release_all_locks.rbs
128
+ - sig/redis_queued_locks/acquirer/release_lock.rbs
129
+ - sig/redis_queued_locks/client.rbs
130
+ - sig/redis_queued_locks/config.rbs
131
+ - sig/redis_queued_locks/config/dsl.rbs
132
+ - sig/redis_queued_locks/data.rbs
133
+ - sig/redis_queued_locks/debugger.rbs
134
+ - sig/redis_queued_locks/debugger/interface.rbs
135
+ - sig/redis_queued_locks/errors.rbs
136
+ - sig/redis_queued_locks/instrument.rbs
137
+ - sig/redis_queued_locks/instrument/active_support.rbs
138
+ - sig/redis_queued_locks/instrument/sampler.rbs
139
+ - sig/redis_queued_locks/instrument/void_notifier.rbs
140
+ - sig/redis_queued_locks/logging.rbs
141
+ - sig/redis_queued_locks/logging/sampler.rbs
142
+ - sig/redis_queued_locks/logging/void_logger.rbs
143
+ - sig/redis_queued_locks/resource.rbs
144
+ - sig/redis_queued_locks/swarm.rbs
145
+ - sig/redis_queued_locks/swarm/acquirers.rbs
146
+ - sig/redis_queued_locks/swarm/flush_zombies.rbs
147
+ - sig/redis_queued_locks/swarm/probe_hosts.rbs
148
+ - sig/redis_queued_locks/swarm/redis_client_builder.rbs
149
+ - sig/redis_queued_locks/swarm/supervisor.rbs
150
+ - sig/redis_queued_locks/swarm/swarm_element.rbs
151
+ - sig/redis_queued_locks/swarm/swarm_element/isolated.rbs
152
+ - sig/redis_queued_locks/swarm/swarm_element/threaded.rbs
153
+ - sig/redis_queued_locks/swarm/zombie_info.rbs
154
+ - sig/redis_queued_locks/utilities.rbs
155
+ - sig/redis_queued_locks/utilities/lock.rbs
156
+ - sig/redis_queued_locks/version.rbs
157
+ - sig/vendor/active_support.rbs
158
+ - sig/vendor/redis_client.rbs
159
+ - sig/vendor/semantic_logger.rbs
116
160
  homepage: https://github.com/0exp/redis_queued_locks
117
161
  licenses:
118
162
  - MIT
@@ -120,7 +164,6 @@ metadata:
120
164
  homepage_uri: https://github.com/0exp/redis_queued_locks
121
165
  source_code_uri: https://github.com/0exp/redis_queued_locks/blob/master
122
166
  changelog_uri: https://github.com/0exp/redis_queued_locks/blob/master/CHANGELOG.md
123
- post_install_message:
124
167
  rdoc_options: []
125
168
  require_paths:
126
169
  - lib
@@ -128,15 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
171
  requirements:
129
172
  - - ">="
130
173
  - !ruby/object:Gem::Version
131
- version: '3.1'
174
+ version: '3.3'
132
175
  required_rubygems_version: !ruby/object:Gem::Requirement
133
176
  requirements:
134
177
  - - ">="
135
178
  - !ruby/object:Gem::Version
136
179
  version: '0'
137
180
  requirements: []
138
- rubygems_version: 3.5.17
139
- signing_key:
181
+ rubygems_version: 3.6.7
140
182
  specification_version: 4
141
183
  summary: Distributed locks with "prioritized lock acquisition queue" capabilities
142
184
  based on the Redis Database.
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 1.7.0
5
- module RedisQueuedLocks::Acquier::AcquireLock::DequeueFromLockQueue::LogVisitor
6
- extend self
7
-
8
- # @param logger [::Logger,#debug]
9
- # @param log_sampled [Boolean]
10
- # @param lock_key [String]
11
- # @param queue_ttl [Integer]
12
- # @param acquier_id [String]
13
- # @param host_id [String]
14
- # @param access_strategy [Symbol]
15
- # @return [void]
16
- #
17
- # @api private
18
- # @since 1.7.0
19
- # @version 1.9.0
20
- def dequeue_from_lock_queue(
21
- logger,
22
- log_sampled,
23
- lock_key,
24
- queue_ttl,
25
- acquier_id,
26
- host_id,
27
- access_strategy
28
- )
29
- return unless log_sampled
30
-
31
- logger.debug do
32
- "[redis_queued_locks.fail_fast_or_limits_reached_or_deadlock__dequeue] " \
33
- "lock_key => '#{lock_key}' " \
34
- "queue_ttl => #{queue_ttl} " \
35
- "acq_id => '#{acquier_id}' " \
36
- "hst_id => '#{host_id}' " \
37
- "acs_strat => '#{access_strategy}"
38
- end rescue nil
39
- end
40
- end
@@ -1,166 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- # @since 1.7.0
5
- module RedisQueuedLocks::Acquier::AcquireLock::InstrVisitor
6
- extend self
7
-
8
- # @param instrumenter [#notify]
9
- # @param instr_sampled [Boolean]
10
- # @param lock_key [String]
11
- # @param ttl [Integer, NilClass]
12
- # @param acq_id [String]
13
- # @param hst_id [String]
14
- # @param ts [Numeric]
15
- # @param acq_time [Numeric]
16
- # @param instrument [NilClass,Any]
17
- # @return [void]
18
- #
19
- # @api private
20
- # @since 1.7.0
21
- # @version 1.9.0
22
- def extendable_reentrant_lock_obtained(
23
- instrumenter,
24
- instr_sampled,
25
- lock_key,
26
- ttl,
27
- acq_id,
28
- hst_id,
29
- ts,
30
- acq_time,
31
- instrument
32
- )
33
- return unless instr_sampled
34
- instrumenter.notify('redis_queued_locks.extendable_reentrant_lock_obtained', {
35
- lock_key:, ttl:, acq_id:, hst_id:, ts:, acq_time:, instrument:
36
- }) rescue nil
37
- end
38
-
39
- # @param instrumenter [#notify]
40
- # @param instr_sampled [Boolean]
41
- # @param lock_key [String]
42
- # @param ttl [Integer, NilClass]
43
- # @param acq_id [String]
44
- # @param hst_id [String]
45
- # @param ts [Numeric]
46
- # @param acq_time [Numeric]
47
- # @param instrument [NilClass,Any]
48
- # @return [void]
49
- #
50
- # @api private
51
- # @since 1.7.0
52
- # @version 1.9.0
53
- def reentrant_lock_obtained(
54
- instrumenter,
55
- instr_sampled,
56
- lock_key,
57
- ttl,
58
- acq_id,
59
- hst_id,
60
- ts,
61
- acq_time,
62
- instrument
63
- )
64
- return unless instr_sampled
65
- instrumenter.notify('redis_queued_locks.reentrant_lock_obtained', {
66
- lock_key:, ttl:, acq_id:, hst_id:, ts:, acq_time:, instrument:
67
- }) rescue nil
68
- end
69
-
70
- # @param instrumenter [#notify]
71
- # @param instr_sampled [Boolean]
72
- # @param lock_key [String]
73
- # @param ttl [Integer, NilClass]
74
- # @param acq_id [String]
75
- # @param hst_id [String]
76
- # @param ts [Numeric]
77
- # @param acq_time [Numeric]
78
- # @param instrument [NilClass,Any]
79
- # @return [void]
80
- #
81
- # @api private
82
- # @since 1.7.0
83
- # @version 1.9.0
84
- def lock_obtained(
85
- instrumenter,
86
- instr_sampled,
87
- lock_key,
88
- ttl,
89
- acq_id,
90
- hst_id,
91
- ts,
92
- acq_time,
93
- instrument
94
- )
95
- return unless instr_sampled
96
- instrumenter.notify('redis_queued_locks.lock_obtained', {
97
- lock_key:, ttl:, acq_id:, hst_id:, ts:, acq_time:, instrument:
98
- }) rescue nil
99
- end
100
-
101
- # @param instrumenter [#notify]
102
- # @param instr_sampled [Boolean]
103
- # @param lock_key [String]
104
- # @param ttl [Integer, NilClass]
105
- # @param acq_id [String]
106
- # @param hst_id [String]
107
- # @param ts [Numeric]
108
- # @param acq_time [Numeric]
109
- # @param hold_time [Numeric]
110
- # @param instrument [NilClass,Any]
111
- # @return [void]
112
- #
113
- # @api private
114
- # @since 1.7.0
115
- # @version 1.9.0
116
- def reentrant_lock_hold_completes(
117
- instrumenter,
118
- instr_sampled,
119
- lock_key,
120
- ttl,
121
- acq_id,
122
- hst_id,
123
- ts,
124
- acq_time,
125
- hold_time,
126
- instrument
127
- )
128
- return unless instr_sampled
129
- instrumenter.notify('redis_queued_locks.reentrant_lock_hold_completes', {
130
- hold_time:, ttl:, acq_id:, hst_id:, ts:, lock_key:, acq_time:, instrument:
131
- }) rescue nil
132
- end
133
-
134
- # @param instrumenter [#notify]
135
- # @param instr_sampled [Boolean]
136
- # @param lock_key [String]
137
- # @param ttl [Integer, NilClass]
138
- # @param acq_id [String]
139
- # @param hst_id [String]
140
- # @param ts [Numeric]
141
- # @param acq_time [Numeric]
142
- # @param hold_time [Numeric]
143
- # @param instrument [NilClass,Any]
144
- # @return [void]
145
- #
146
- # @api private
147
- # @since 1.7.0
148
- # @version 1.9.0
149
- def lock_hold_and_release(
150
- instrumenter,
151
- instr_sampled,
152
- lock_key,
153
- ttl,
154
- acq_id,
155
- hst_id,
156
- ts,
157
- acq_time,
158
- hold_time,
159
- instrument
160
- )
161
- return unless instr_sampled
162
- instrumenter.notify('redis_queued_locks.lock_hold_and_release', {
163
- hold_time:, ttl:, acq_id:, hst_id:, ts:, lock_key:, acq_time:, instrument:
164
- }) rescue nil
165
- end
166
- end