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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e8dd94852534ed373615917be290e53b29e203e7b88907d24631869ab4f2deb
4
- data.tar.gz: 9b78929772d22f8ae6cbb628d306a85c44d4eec2f6a41e68bccfa0d754db80b5
3
+ metadata.gz: 306e86a36b29ee294af7e0ee9eda0c3815e1b646733abf3f30e25c4f0d3f0394
4
+ data.tar.gz: 1f4b4d1b762f4c27aab1bfae415c2f183593ab5a2772b07e4789d44aa0b5ea1c
5
5
  SHA512:
6
- metadata.gz: 14e6e0c7ff71c9bc0d8a4ff1088a0b9983a8bd365fa10b17236996b3cb20e291fb951e648c79430b2d4091179024385648a343b36913443a9459c3c9e2a71b18
7
- data.tar.gz: f0aa55c8561513a87d3c8f347db2f9a0710c62b4fe6d03fd6b512fec56c2631da77b86080bbbdf051bfc82d6abe2016f8baf37e43b3eebc973bd404bb7f80a35
6
+ metadata.gz: f48e55fece224be62a769d2eaba83fe206b3275fed1849dc000dfd75d51794a1f023af43c4a0647809fc6ee6fb8d80258e2686d9b1f59fa3ff3a0b20651db89b
7
+ data.tar.gz: 338a6748a479158d2429c57b6afab1d10682b94e1751560c595c4d9dadd0a607b1d3ea45aeb5612b003a0a88d208780e7dcdb474f05418ac817a46bb9bd16de1
data/.rubocop.yml CHANGED
@@ -3,14 +3,17 @@ inherit_gem:
3
3
  - lib/rubocop.general.yml
4
4
  - lib/rubocop.rake.yml
5
5
  - lib/rubocop.rspec.yml
6
+ - lib/rubocop.rbs.yml
6
7
 
7
8
  AllCops:
8
- TargetRubyVersion: 3.1
9
+ TargetRubyVersion: 3.3
9
10
  NewCops: enable
10
11
  Include:
11
12
  - lib/**/*.rb
12
13
  - spec/**/*.rb
14
+ - sig/**/*.rbs
13
15
  - Gemfile
16
+ - gemfiles/ruby3.3.gemfile
14
17
  - Rakefile
15
18
  - redis_queued_locks.gemspec
16
19
  - bin/console
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.4
1
+ 3.4.3
data/CHANGELOG.md CHANGED
@@ -1,4 +1,41 @@
1
1
  ## [Unreleased]
2
+ ### Changed
3
+ - Updated development dependencies (`armitage-rubocop`, `rbs`, `steep`);
4
+ - Bumped development Ruby version (from `3.3.6` to `3.4.3`);
5
+ - CI is splitted to "mainstream ruby version" and "previous actually maintaned ruby versions";
6
+ - `Acquier` -> `Acquirer`, `Acquierment` -> `Acquirement` (typos):
7
+ - [**Breaking**] Constant renaming: all constants and constant parts were renamed from `Acquier` to `Acquirer`;
8
+ - [**Breaking**] Method and variable names renaming: all `acquier` text parts of method/variable names were renamed to `acquirer`;
9
+ - [**Breaking**] Logs: all `acquier` text parts of each log message type were renamed to `acquirer`;
10
+ - [**Breaking**] Instrumentation: all `acquier` text parts of each event name were renamed to `acquirer`;
11
+ - [**Breaking**] Exceptions: all `Acquierment` exception constant name parts were renamed to `Acquirement`;
12
+ - [**Breaking**] `RedisQueuedLocks::Data` is not used (**temporary**) as result type of some APIs.
13
+ The reason is that this type can not be used as a record type in `steep`/`rbs` (working on it);
14
+ - [**Breaking**] Minimal Ruby Version - **3.3** (previously - **3.1**):
15
+ - removed `3.1` and `3.2` from `CI`;
16
+ - [**Breaking**] Config layer was fully reworked in order to improve performance:
17
+ - Config API has changed from "method invocation" to "hash key/value access/assignment" with a validation layer and config-data-access wrapping;
18
+ ### Added
19
+ - **Type Checking**:
20
+ - library codebase is fully typed;
21
+ - integrated `RBS` with `Steep` that is configured on **strict mode** (see `sig` directory, `Steepfile` config, `sig/manifest.yml` and `rbs_collection.yml` for dependencies);
22
+ - CI integration;
23
+ - Integrated RBS linting to `Rubocop`;
24
+ - Test coverage (via `simplecov` with `html` and `lcov` formats). `minimum_coverage` config is temporary disabled (and the CI step is not configured yet) cuz we need to refactor tests in first;
25
+ - CI:
26
+ - `rspec-retry` is temporary added until the tests are fully refactored;
27
+ - typecheck steps: `TypeCheck (Static)` (based on `steep` checks) and `TypeCheckl (Runtime)` (based on `RBS` runtime type checking/testing);
28
+ - Support for `ActiveSupport::BroadcastLogger` logger instances;
29
+
30
+ ## [1.12.1]
31
+ ### Changed
32
+ - Internal Private API: an internal Reentrant's Lock utility (`RedisQueuedLocks::Utilities::Lock`) basis
33
+ is changed from `::Mutex` to `::Monitor` in order to use Ruby's Core C-based
34
+ implementation (prevent some Ruby-runtime based GVL-oriented locking) of re-entrant locks
35
+ instead of the custom Ruby-based implementation;
36
+ ### Fixed
37
+ - `redis_queued_locks.lock_hold_and_release` instrumentation event has incorrect `acq_time` payload value
38
+ (it incorrectly stores `lock_key` payload value);
2
39
 
3
40
  ## [1.12.0] - 2024-08-11
4
41
  ### Changed
@@ -6,7 +43,7 @@
6
43
 
7
44
  ## [1.11.0] - 2024-08-11
8
45
  ### Changed
9
- - Lock Acquierment Timeout (`acq_timeout`/`queue_ttl`): more correct timeout error interception
46
+ - Lock Acquirement Timeout (`acq_timeout`/`queue_ttl`): more correct timeout error interception
10
47
  inside the `RedisQueuedLocks::Acquier::AcquireLock::WithAcqTimeout` logic that now raises and
11
48
  intercepts an internal timeout error class in order to prevent interceptions of
12
49
  other timeouts that can be raised from the wrapped block of code;
@@ -36,7 +73,7 @@
36
73
  - each ruby worker of the swarm probes himself that he is alive;
37
74
  - worker that does not probes himselfs treats as a zombie;
38
75
  - worekr becomes dead when your ruby process is dead, or thread is dead or your ractor is dead;
39
- - each zombie's lock, acquier and position in queue are flushed in background via `flush_zombies` swarm element;
76
+ - each zombie's lock, acquirer and position in queue are flushed in background via `flush_zombies` swarm element;
40
77
  - the supervisor module keeps up and running each swarm melement (`probe_hosts` and `flush_zombies`):
41
78
  - cuz each element works in background and can fail by any unexpected exception the supervisor guarantees that your elements will ressurect after that;
42
79
  - each element can be deeply configured (and enabled/disabled);
@@ -47,7 +84,7 @@
47
84
  - supervisor that keeps all elements running and wokring;
48
85
  - an ability to check the swarm status (`#swarm_status`): who is working, who is dead, running status, internal main loop states, etc;
49
86
  - an abiltiy to check the swarm information (`#swarm_info`): showing the current swarm hosts and their last probes and current zombie status;
50
- - an ability to find zombie locks, zombie acquiers and zombie hosts (`#zombie_locks`, `#zombie_acquiers`, `#zombie_hosts`);
87
+ - an ability to find zombie locks, zombie acquirers and zombie hosts (`#zombie_locks`, `#zombie_acquiers`, `#zombie_hosts`);
51
88
  - an ability to extract the full zombie information (`#zombies_info`/`#zombies`);
52
89
  - each zombie lock will be flushed in background by appropriated swarm element (`flush_zombies`);
53
90
  - deeply configurable zombie factors: zombie ttl, host probing period, supervisor check period;
@@ -246,7 +283,7 @@
246
283
 
247
284
  ## [0.0.27] - 2024-03-21
248
285
  ### Changed
249
- - Better acquier position accuracy: acquier position in lock queue
286
+ - Better acquirer position accuracy: acquirer position in lock queue
250
287
  should be represented as EPOCH in seconds+microseconds (previously: simply in seconds);
251
288
 
252
289
  ## [0.0.26] - 2024-03-21
@@ -325,7 +362,7 @@
325
362
 
326
363
  ## [0.0.9] - 2024-02-27
327
364
  ### Changed
328
- - The lock acquier identifier (`acq_id`) now includes the fiber id, the ractor id and an unique per-process
365
+ - The lock acquirer identifier (`acq_id`) now includes the fiber id, the ractor id and an unique per-process
329
366
  10 byte string. It is added in order to prevent collisions between different processes/pods
330
367
  that will have the same process id / thread id identifiers (cuz it is an object_id integers) that can lead
331
368
  to the same position with the same `acq_id` for different processes/pods in the lock request queue.
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Rustam Ibragimov
3
+ Copyright (c) 2024-2025 Rustam Ibragimov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal