redis_queued_locks 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.rubocop.yml +0 -1
 - data/.ruby-version +1 -1
 - data/CHANGELOG.md +21 -4
 - data/README.md +368 -107
 - data/Rakefile +1 -1
 - data/Steepfile +0 -1
 - data/github_ci/ruby3.3.gemfile.lock +23 -23
 - data/lib/redis_queued_locks/acquirer/acquire_lock.rb +7 -7
 - data/lib/redis_queued_locks/acquirer/release_all_locks.rb +3 -3
 - data/lib/redis_queued_locks/acquirer/release_lock.rb +3 -3
 - data/lib/redis_queued_locks/acquirer/release_locks_of.rb +221 -0
 - data/lib/redis_queued_locks/acquirer.rb +1 -0
 - data/lib/redis_queued_locks/client.rb +155 -2
 - data/lib/redis_queued_locks/config/dsl.rb +9 -9
 - data/lib/redis_queued_locks/config.rb +15 -10
 - data/lib/redis_queued_locks/errors.rb +3 -3
 - data/lib/redis_queued_locks/swarm.rb +1 -1
 - data/lib/redis_queued_locks/utilities.rb +9 -0
 - data/lib/redis_queued_locks/version.rb +2 -2
 - data/lib/redis_queued_locks.rb +0 -1
 - data/rbs_collection.lock.yaml +1 -13
 - data/rbs_collection.yaml +2 -1
 - data/redis_queued_locks.gemspec +1 -1
 - data/sig/manifest.yml +0 -1
 - data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +1 -0
 - data/sig/redis_queued_locks/acquirer/release_locks_of.rbs +46 -0
 - data/sig/redis_queued_locks/client.rbs +40 -0
 - data/sig/redis_queued_locks/utilities.rbs +1 -0
 - metadata +5 -3
 
| 
         @@ -1,10 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            # @api private
         
     | 
| 
       4 
     | 
    
         
            -
            # @since  
     | 
| 
      
 4 
     | 
    
         
            +
            # @since 1.13.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            module RedisQueuedLocks::Config::DSL
         
     | 
| 
       6 
6 
     | 
    
         
             
              # @api private
         
     | 
| 
       7 
     | 
    
         
            -
              # @since  
     | 
| 
      
 7 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       8 
8 
     | 
    
         
             
              module ClassMethods
         
     | 
| 
       9 
9 
     | 
    
         
             
                # NOTE:
         
     | 
| 
       10 
10 
     | 
    
         
             
                #   1. Style/DefWithParentheses rubocop's cop incorrectly drops `()` from method definition
         
     | 
| 
         @@ -15,7 +15,7 @@ module RedisQueuedLocks::Config::DSL 
     | 
|
| 
       15 
15 
     | 
    
         
             
                # @return [Hash<String,Block>]
         
     | 
| 
       16 
16 
     | 
    
         
             
                #
         
     | 
| 
       17 
17 
     | 
    
         
             
                # @api private
         
     | 
| 
       18 
     | 
    
         
            -
                # @since  
     | 
| 
      
 18 
     | 
    
         
            +
                # @since 1.13.0
         
     | 
| 
       19 
19 
     | 
    
         
             
                def config_setters()= @config_setters # rubocop:disable Style/DefWithParentheses
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                # NOTE:
         
     | 
| 
         @@ -27,7 +27,7 @@ module RedisQueuedLocks::Config::DSL 
     | 
|
| 
       27 
27 
     | 
    
         
             
                # @return [Hash<String,Block>]
         
     | 
| 
       28 
28 
     | 
    
         
             
                #
         
     | 
| 
       29 
29 
     | 
    
         
             
                # @api private
         
     | 
| 
       30 
     | 
    
         
            -
                # @since  
     | 
| 
      
 30 
     | 
    
         
            +
                # @since 1.13.0
         
     | 
| 
       31 
31 
     | 
    
         
             
                def config_validators()= @config_validators # rubocop:disable Style/DefWithParentheses
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                # @param config_key [String]
         
     | 
| 
         @@ -35,7 +35,7 @@ module RedisQueuedLocks::Config::DSL 
     | 
|
| 
       35 
35 
     | 
    
         
             
                # @return [Bool]
         
     | 
| 
       36 
36 
     | 
    
         
             
                #
         
     | 
| 
       37 
37 
     | 
    
         
             
                # @api private
         
     | 
| 
       38 
     | 
    
         
            -
                # @since  
     | 
| 
      
 38 
     | 
    
         
            +
                # @since 1.13.0
         
     | 
| 
       39 
39 
     | 
    
         
             
                def validate(config_key, &validator)
         
     | 
| 
       40 
40 
     | 
    
         
             
                  config_validators[config_key] = validator
         
     | 
| 
       41 
41 
     | 
    
         
             
                end
         
     | 
| 
         @@ -45,7 +45,7 @@ module RedisQueuedLocks::Config::DSL 
     | 
|
| 
       45 
45 
     | 
    
         
             
                # @return [void]
         
     | 
| 
       46 
46 
     | 
    
         
             
                #
         
     | 
| 
       47 
47 
     | 
    
         
             
                # @api private
         
     | 
| 
       48 
     | 
    
         
            -
                # @since  
     | 
| 
      
 48 
     | 
    
         
            +
                # @since 1.13.0
         
     | 
| 
       49 
49 
     | 
    
         
             
                def setting(config_key, config_value)
         
     | 
| 
       50 
50 
     | 
    
         
             
                  config_setters[config_key] = proc do |config|
         
     | 
| 
       51 
51 
     | 
    
         
             
                    config[config_key] = config_value
         
     | 
| 
         @@ -57,7 +57,7 @@ module RedisQueuedLocks::Config::DSL 
     | 
|
| 
       57 
57 
     | 
    
         
             
                # @return [Hash<String,Blcok>]
         
     | 
| 
       58 
58 
     | 
    
         
             
                #
         
     | 
| 
       59 
59 
     | 
    
         
             
                # @api private
         
     | 
| 
       60 
     | 
    
         
            -
                # @since  
     | 
| 
      
 60 
     | 
    
         
            +
                # @since 1.13.0
         
     | 
| 
       61 
61 
     | 
    
         
             
                def config_setters
         
     | 
| 
       62 
62 
     | 
    
         
             
                  self.class.config_setters # steep:ignore
         
     | 
| 
       63 
63 
     | 
    
         
             
                end
         
     | 
| 
         @@ -65,7 +65,7 @@ module RedisQueuedLocks::Config::DSL 
     | 
|
| 
       65 
65 
     | 
    
         
             
                # @return [Hash<String,Blcok>]
         
     | 
| 
       66 
66 
     | 
    
         
             
                #
         
     | 
| 
       67 
67 
     | 
    
         
             
                # @api private
         
     | 
| 
       68 
     | 
    
         
            -
                # @since  
     | 
| 
      
 68 
     | 
    
         
            +
                # @since 1.13.0
         
     | 
| 
       69 
69 
     | 
    
         
             
                def config_validators
         
     | 
| 
       70 
70 
     | 
    
         
             
                  self.class.config_validators # steep:ignore
         
     | 
| 
       71 
71 
     | 
    
         
             
                end
         
     | 
| 
         @@ -76,7 +76,7 @@ module RedisQueuedLocks::Config::DSL 
     | 
|
| 
       76 
76 
     | 
    
         
             
                # @return [void]
         
     | 
| 
       77 
77 
     | 
    
         
             
                #
         
     | 
| 
       78 
78 
     | 
    
         
             
                # @api private
         
     | 
| 
       79 
     | 
    
         
            -
                # @since  
     | 
| 
      
 79 
     | 
    
         
            +
                # @since 1.13.0
         
     | 
| 
       80 
80 
     | 
    
         
             
                def included(child_klass)
         
     | 
| 
       81 
81 
     | 
    
         
             
                  child_klass.instance_variable_set(
         
     | 
| 
       82 
82 
     | 
    
         
             
                    :@config_setters,
         
     | 
| 
         @@ -1,13 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            # @api private
         
     | 
| 
       4 
     | 
    
         
            -
            # @since  
     | 
| 
      
 4 
     | 
    
         
            +
            # @since 1.13.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            # @version 1.14.0
         
     | 
| 
       5 
6 
     | 
    
         
             
            # rubocop:disable Metrics/ClassLength
         
     | 
| 
       6 
7 
     | 
    
         
             
            class RedisQueuedLocks::Config
         
     | 
| 
       7 
8 
     | 
    
         
             
              require_relative 'config/dsl'
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
              # @api private
         
     | 
| 
       10 
     | 
    
         
            -
              # @since  
     | 
| 
      
 11 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       11 
12 
     | 
    
         
             
              include DSL
         
     | 
| 
       12 
13 
     | 
    
         | 
| 
       13 
14 
     | 
    
         
             
              setting('retry_count', 3)
         
     | 
| 
         @@ -18,6 +19,8 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       18 
19 
     | 
    
         
             
              setting('default_queue_ttl', 15) # NOTE: in seconds)
         
     | 
| 
       19 
20 
     | 
    
         
             
              setting('detailed_acq_timeout_error', false)
         
     | 
| 
       20 
21 
     | 
    
         
             
              setting('lock_release_batch_size', 100)
         
     | 
| 
      
 22 
     | 
    
         
            +
              setting('clear_locks_of__lock_scan_size', 300)
         
     | 
| 
      
 23 
     | 
    
         
            +
              setting('clear_locks_of__queue_scan_size', 300)
         
     | 
| 
       21 
24 
     | 
    
         
             
              setting('key_extraction_batch_size', 500)
         
     | 
| 
       22 
25 
     | 
    
         
             
              setting('instrumenter', RedisQueuedLocks::Instrument::VoidNotifier)
         
     | 
| 
       23 
26 
     | 
    
         
             
              setting('uniq_identifier', -> { RedisQueuedLocks::Resource.calc_uniq_identity })
         
     | 
| 
         @@ -79,6 +82,8 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       79 
82 
     | 
    
         
             
              validate('default_queue_ttl') { |val| val.is_a?(Integer) }
         
     | 
| 
       80 
83 
     | 
    
         
             
              validate('detailed_acq_timeout_error') { |val| val == true || val == false }
         
     | 
| 
       81 
84 
     | 
    
         
             
              validate('lock_release_batch_size') { |val| val.is_a?(Integer) }
         
     | 
| 
      
 85 
     | 
    
         
            +
              validate('clear_locks_of__lock_scan_size') { |val| val.is_a?(Integer) }
         
     | 
| 
      
 86 
     | 
    
         
            +
              validate('clear_locks_of__queue_scan_size') { |val| val.is_a?(Integer) }
         
     | 
| 
       82 
87 
     | 
    
         
             
              validate('instrumenter') { |val| RedisQueuedLocks::Instrument.valid_interface?(val) }
         
     | 
| 
       83 
88 
     | 
    
         
             
              validate('uniq_identifier') { |val| val.is_a?(Proc) }
         
     | 
| 
       84 
89 
     | 
    
         
             
              validate('logger') { |val| RedisQueuedLocks::Logging.valid_interface?(val) }
         
     | 
| 
         @@ -109,13 +114,13 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       109 
114 
     | 
    
         
             
              # @return [Hash<Symbol,Any>]
         
     | 
| 
       110 
115 
     | 
    
         
             
              #
         
     | 
| 
       111 
116 
     | 
    
         
             
              # @api private
         
     | 
| 
       112 
     | 
    
         
            -
              # @since  
     | 
| 
      
 117 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       113 
118 
     | 
    
         
             
              attr_reader :config_state
         
     | 
| 
       114 
119 
     | 
    
         | 
| 
       115 
120 
     | 
    
         
             
              # @return [void]
         
     | 
| 
       116 
121 
     | 
    
         
             
              #
         
     | 
| 
       117 
122 
     | 
    
         
             
              # @api private
         
     | 
| 
       118 
     | 
    
         
            -
              # @since  
     | 
| 
      
 123 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       119 
124 
     | 
    
         
             
              def initialize(&configuration)
         
     | 
| 
       120 
125 
     | 
    
         
             
                @config_state = {}
         
     | 
| 
       121 
126 
     | 
    
         
             
                config_setters.each_value { |setter| setter.call(@config_state) }
         
     | 
| 
         @@ -128,7 +133,7 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       128 
133 
     | 
    
         
             
              # @return [void]
         
     | 
| 
       129 
134 
     | 
    
         
             
              #
         
     | 
| 
       130 
135 
     | 
    
         
             
              # @api private
         
     | 
| 
       131 
     | 
    
         
            -
              # @since  
     | 
| 
      
 136 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       132 
137 
     | 
    
         
             
              def configure(&configuration)
         
     | 
| 
       133 
138 
     | 
    
         
             
                yield(self) if block_given?
         
     | 
| 
       134 
139 
     | 
    
         
             
              end
         
     | 
| 
         @@ -139,7 +144,7 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       139 
144 
     | 
    
         
             
              # @raise [RedisQueuedLocks::ConfigNotFoundError]
         
     | 
| 
       140 
145 
     | 
    
         
             
              #
         
     | 
| 
       141 
146 
     | 
    
         
             
              # @api public
         
     | 
| 
       142 
     | 
    
         
            -
              # @since  
     | 
| 
      
 147 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       143 
148 
     | 
    
         
             
              def [](config_key)
         
     | 
| 
       144 
149 
     | 
    
         
             
                prevent_key__non_existent(config_key)
         
     | 
| 
       145 
150 
     | 
    
         
             
                config_state[config_key]
         
     | 
| 
         @@ -153,7 +158,7 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       153 
158 
     | 
    
         
             
              # @raise [RedisQueuedLocks::ConfigValidationError]
         
     | 
| 
       154 
159 
     | 
    
         
             
              #
         
     | 
| 
       155 
160 
     | 
    
         
             
              # @api public
         
     | 
| 
       156 
     | 
    
         
            -
              # @since  
     | 
| 
      
 161 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       157 
162 
     | 
    
         
             
              def []=(config_key, config_value)
         
     | 
| 
       158 
163 
     | 
    
         
             
                prevent_key__non_existent(config_key)
         
     | 
| 
       159 
164 
     | 
    
         
             
                prevent_key__invalid_type(config_key, config_value)
         
     | 
| 
         @@ -178,7 +183,7 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       178 
183 
     | 
    
         
             
              # @return [Hash<String,Any>]
         
     | 
| 
       179 
184 
     | 
    
         
             
              #
         
     | 
| 
       180 
185 
     | 
    
         
             
              # @api public
         
     | 
| 
       181 
     | 
    
         
            -
              # @since  
     | 
| 
      
 186 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       182 
187 
     | 
    
         
             
              def slice(config_key_pattern)
         
     | 
| 
       183 
188 
     | 
    
         
             
                key_selector = "#{config_key_pattern}."
         
     | 
| 
       184 
189 
     | 
    
         
             
                key_splitter = key_selector.size
         
     | 
| 
         @@ -201,7 +206,7 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       201 
206 
     | 
    
         
             
              # @raise [RedisQueuedLocks::ConfigNotFoundError]
         
     | 
| 
       202 
207 
     | 
    
         
             
              #
         
     | 
| 
       203 
208 
     | 
    
         
             
              # @api private
         
     | 
| 
       204 
     | 
    
         
            -
              # @since  
     | 
| 
      
 209 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       205 
210 
     | 
    
         
             
              def prevent_key__non_existent(config_key)
         
     | 
| 
       206 
211 
     | 
    
         
             
                unless config_state.key?(config_key)
         
     | 
| 
       207 
212 
     | 
    
         
             
                  raise(
         
     | 
| 
         @@ -218,7 +223,7 @@ class RedisQueuedLocks::Config 
     | 
|
| 
       218 
223 
     | 
    
         
             
              # @raise [RedisQueuedLocks::ConfigValidationError]
         
     | 
| 
       219 
224 
     | 
    
         
             
              #
         
     | 
| 
       220 
225 
     | 
    
         
             
              # @api private
         
     | 
| 
       221 
     | 
    
         
            -
              # @ 
     | 
| 
      
 226 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       222 
227 
     | 
    
         
             
              def prevent_key__invalid_type(config_key, config_value)
         
     | 
| 
       223 
228 
     | 
    
         
             
                unless config_validators[config_key].call(config_value)
         
     | 
| 
       224 
229 
     | 
    
         
             
                  raise(
         
     | 
| 
         @@ -50,14 +50,14 @@ module RedisQueuedLocks 
     | 
|
| 
       50 
50 
     | 
    
         
             
              class SwarmArgumentError < ArgumentError; end
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
52 
     | 
    
         
             
              # @api public
         
     | 
| 
       53 
     | 
    
         
            -
              # @since  
     | 
| 
      
 53 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       54 
54 
     | 
    
         
             
              class ConfigError < Error; end
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
       56 
56 
     | 
    
         
             
              # @api public
         
     | 
| 
       57 
     | 
    
         
            -
              # @since  
     | 
| 
      
 57 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       58 
58 
     | 
    
         
             
              class ConfigNotFoundError < ConfigError; end
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
60 
     | 
    
         
             
              # @api pub;ic
         
     | 
| 
       61 
     | 
    
         
            -
              # @since  
     | 
| 
      
 61 
     | 
    
         
            +
              # @since 1.13.0
         
     | 
| 
       62 
62 
     | 
    
         
             
              class ConfigValidationError < ConfigError; end
         
     | 
| 
       63 
63 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,6 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            # @api private
         
     | 
| 
       4 
4 
     | 
    
         
             
            # @since 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            # @version 1.14.0
         
     | 
| 
       5 
6 
     | 
    
         
             
            module RedisQueuedLocks::Utilities
         
     | 
| 
       6 
7 
     | 
    
         
             
              require_relative 'utilities/lock'
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
         @@ -44,6 +45,14 @@ module RedisQueuedLocks::Utilities 
     | 
|
| 
       44 
45 
     | 
    
         
             
                yield rescue nil
         
     | 
| 
       45 
46 
     | 
    
         
             
              end
         
     | 
| 
       46 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
              # @return [Integer]
         
     | 
| 
      
 49 
     | 
    
         
            +
              #
         
     | 
| 
      
 50 
     | 
    
         
            +
              # @api private
         
     | 
| 
      
 51 
     | 
    
         
            +
              # @since 1.14.0
         
     | 
| 
      
 52 
     | 
    
         
            +
              def clock_gettime
         
     | 
| 
      
 53 
     | 
    
         
            +
                ::Process.clock_gettime(::Process::CLOCK_MONOTONIC, :microsecond)
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
       47 
56 
     | 
    
         
             
              # Possible statuses (at the moment of Ruby@3.4):
         
     | 
| 
       48 
57 
     | 
    
         
             
              #   - "created"
         
     | 
| 
       49 
58 
     | 
    
         
             
              #   - "blocking"
         
     | 
    
        data/lib/redis_queued_locks.rb
    CHANGED
    
    
    
        data/rbs_collection.lock.yaml
    CHANGED
    
    | 
         @@ -1,20 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            path: ".gem_rbs_collection"
         
     | 
| 
       3 
3 
     | 
    
         
             
            gems:
         
     | 
| 
       4 
     | 
    
         
            -
            - name: base64
         
     | 
| 
       5 
     | 
    
         
            -
              version: '0.1'
         
     | 
| 
       6 
     | 
    
         
            -
              source:
         
     | 
| 
       7 
     | 
    
         
            -
                type: git
         
     | 
| 
       8 
     | 
    
         
            -
                name: ruby/gem_rbs_collection
         
     | 
| 
       9 
     | 
    
         
            -
                revision: e2749137770bcff57a062d47b0d08922071f3d37
         
     | 
| 
       10 
     | 
    
         
            -
                remote: https://github.com/ruby/gem_rbs_collection.git
         
     | 
| 
       11 
     | 
    
         
            -
                repo_dir: gems
         
     | 
| 
       12 
4 
     | 
    
         
             
            - name: connection_pool
         
     | 
| 
       13 
5 
     | 
    
         
             
              version: '2.4'
         
     | 
| 
       14 
6 
     | 
    
         
             
              source:
         
     | 
| 
       15 
7 
     | 
    
         
             
                type: git
         
     | 
| 
       16 
8 
     | 
    
         
             
                name: ruby/gem_rbs_collection
         
     | 
| 
       17 
     | 
    
         
            -
                revision:  
     | 
| 
      
 9 
     | 
    
         
            +
                revision: 52a7ef8a9328fb2413e3b42dd8ee37deb703a940
         
     | 
| 
       18 
10 
     | 
    
         
             
                remote: https://github.com/ruby/gem_rbs_collection.git
         
     | 
| 
       19 
11 
     | 
    
         
             
                repo_dir: gems
         
     | 
| 
       20 
12 
     | 
    
         
             
            - name: logger
         
     | 
| 
         @@ -25,10 +17,6 @@ gems: 
     | 
|
| 
       25 
17 
     | 
    
         
             
              version: '0'
         
     | 
| 
       26 
18 
     | 
    
         
             
              source:
         
     | 
| 
       27 
19 
     | 
    
         
             
                type: stdlib
         
     | 
| 
       28 
     | 
    
         
            -
            - name: objspace
         
     | 
| 
       29 
     | 
    
         
            -
              version: '0'
         
     | 
| 
       30 
     | 
    
         
            -
              source:
         
     | 
| 
       31 
     | 
    
         
            -
                type: stdlib
         
     | 
| 
       32 
20 
     | 
    
         
             
            - name: securerandom
         
     | 
| 
       33 
21 
     | 
    
         
             
              version: '0'
         
     | 
| 
       34 
22 
     | 
    
         
             
              source:
         
     | 
    
        data/rbs_collection.yaml
    CHANGED
    
    
    
        data/redis_queued_locks.gemspec
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       18 
18 
     | 
    
         
             
                "|> Distributed locks with \"prioritized lock acquisition queue\" capabilities " \
         
     | 
| 
       19 
19 
     | 
    
         
             
                "based on the Redis Database.\n" \
         
     | 
| 
       20 
20 
     | 
    
         
             
                "|> Each lock request is put into the request queue " \
         
     | 
| 
       21 
     | 
    
         
            -
                "(each lock is hosted by  
     | 
| 
      
 21 
     | 
    
         
            +
                "(each lock is hosted by its own queue separately from other queues) and processed " \
         
     | 
| 
       22 
22 
     | 
    
         
             
                "in order of their priority (FIFO).\n" \
         
     | 
| 
       23 
23 
     | 
    
         
             
                "|> Each lock request lives some period of time (RTTL) " \
         
     | 
| 
       24 
24 
     | 
    
         
             
                "(with requeue capabilities) which guarantees the request queue will never be stacked.\n" \
         
     | 
    
        data/sig/manifest.yml
    CHANGED
    
    
| 
         @@ -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
         
     | 
| 
         @@ -121,6 +121,8 @@ module RedisQueuedLocks 
     | 
|
| 
       121 
121 
     | 
    
         
             
                  ?ractor_id: Integer|String,
         
     | 
| 
       122 
122 
     | 
    
         
             
                  ?identity: String
         
     | 
| 
       123 
123 
     | 
    
         
             
                ) -> String
         
     | 
| 
      
 124 
     | 
    
         
            +
                alias ccurrent_acq_id current_acquirer_id
         
     | 
| 
      
 125 
     | 
    
         
            +
                alias acq_id current_acquirer_id
         
     | 
| 
       124 
126 
     | 
    
         | 
| 
       125 
127 
     | 
    
         
             
                def current_host_id: (
         
     | 
| 
       126 
128 
     | 
    
         
             
                  ?process_id: Integer|String,
         
     | 
| 
         @@ -128,6 +130,8 @@ module RedisQueuedLocks 
     | 
|
| 
       128 
130 
     | 
    
         
             
                  ?ractor_id: Integer|String,
         
     | 
| 
       129 
131 
     | 
    
         
             
                  ?identity: String
         
     | 
| 
       130 
132 
     | 
    
         
             
                ) -> String
         
     | 
| 
      
 133 
     | 
    
         
            +
                alias current_hst_id current_host_id
         
     | 
| 
      
 134 
     | 
    
         
            +
                alias hst_id current_host_id
         
     | 
| 
       131 
135 
     | 
    
         | 
| 
       132 
136 
     | 
    
         
             
                def possible_host_ids: (?String identity) -> Array[String]
         
     | 
| 
       133 
137 
     | 
    
         | 
| 
         @@ -163,6 +167,42 @@ module RedisQueuedLocks 
     | 
|
| 
       163 
167 
     | 
    
         
             
                ) -> RQL::Acquirer::ReleaseAllLocks::releaseResult
         
     | 
| 
       164 
168 
     | 
    
         
             
                alias release_locks clear_locks
         
     | 
| 
       165 
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 
     | 
    
         
            +
             
     | 
| 
       166 
206 
     | 
    
         
             
                def locks: (?scan_size: Integer, ?with_info: bool) -> RQL::Acquirer::Locks::locks
         
     | 
| 
       167 
207 
     | 
    
         
             
                         | (?scan_size: Integer, ?with_info: true) -> RQL::Acquirer::Locks::locksInfo
         
     | 
| 
       168 
208 
     | 
    
         
             
                         | (?scan_size: Integer, ?with_info: false) -> RQL::Acquirer::Locks::lockList
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: redis_queued_locks
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.15.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Rustam Ibragimov
         
     | 
| 
         @@ -25,7 +25,7 @@ dependencies: 
     | 
|
| 
       25 
25 
     | 
    
         
             
                    version: '0.20'
         
     | 
| 
       26 
26 
     | 
    
         
             
            description: |-
         
     | 
| 
       27 
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  
     | 
| 
      
 28 
     | 
    
         
            +
              |> Each lock request is put into the request queue (each lock is hosted by its own queue separately from other queues) and processed in order of their priority (FIFO).
         
     | 
| 
       29 
29 
     | 
    
         
             
              |> Each lock request lives some period of time (RTTL) (with requeue capabilities) which guarantees the request queue will never be stacked.
         
     | 
| 
       30 
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 
31 
     | 
    
         
             
              |> Provides flexible invocation flow, parametrized limits (lock request ttl, lock ttl, queue ttl, lock attempts limit, fast failing, etc), logging and instrumentation.
         
     | 
| 
         @@ -70,6 +70,7 @@ files: 
     | 
|
| 
       70 
70 
     | 
    
         
             
            - lib/redis_queued_locks/acquirer/queues.rb
         
     | 
| 
       71 
71 
     | 
    
         
             
            - lib/redis_queued_locks/acquirer/release_all_locks.rb
         
     | 
| 
       72 
72 
     | 
    
         
             
            - lib/redis_queued_locks/acquirer/release_lock.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - lib/redis_queued_locks/acquirer/release_locks_of.rb
         
     | 
| 
       73 
74 
     | 
    
         
             
            - lib/redis_queued_locks/client.rb
         
     | 
| 
       74 
75 
     | 
    
         
             
            - lib/redis_queued_locks/config.rb
         
     | 
| 
       75 
76 
     | 
    
         
             
            - lib/redis_queued_locks/config/dsl.rb
         
     | 
| 
         @@ -126,6 +127,7 @@ files: 
     | 
|
| 
       126 
127 
     | 
    
         
             
            - sig/redis_queued_locks/acquirer/queues.rbs
         
     | 
| 
       127 
128 
     | 
    
         
             
            - sig/redis_queued_locks/acquirer/release_all_locks.rbs
         
     | 
| 
       128 
129 
     | 
    
         
             
            - sig/redis_queued_locks/acquirer/release_lock.rbs
         
     | 
| 
      
 130 
     | 
    
         
            +
            - sig/redis_queued_locks/acquirer/release_locks_of.rbs
         
     | 
| 
       129 
131 
     | 
    
         
             
            - sig/redis_queued_locks/client.rbs
         
     | 
| 
       130 
132 
     | 
    
         
             
            - sig/redis_queued_locks/config.rbs
         
     | 
| 
       131 
133 
     | 
    
         
             
            - sig/redis_queued_locks/config/dsl.rbs
         
     | 
| 
         @@ -178,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       178 
180 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       179 
181 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       180 
182 
     | 
    
         
             
            requirements: []
         
     | 
| 
       181 
     | 
    
         
            -
            rubygems_version: 3.6. 
     | 
| 
      
 183 
     | 
    
         
            +
            rubygems_version: 3.6.9
         
     | 
| 
       182 
184 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       183 
185 
     | 
    
         
             
            summary: Distributed locks with "prioritized lock acquisition queue" capabilities
         
     | 
| 
       184 
186 
     | 
    
         
             
              based on the Redis Database.
         
     |