sidekiq-limit_fetch 4.3.2 → 4.4.1
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/.github/workflows/ci.yml +3 -1
 - data/.rubocop.yml +29 -0
 - data/Appraisals +6 -0
 - data/Gemfile +2 -0
 - data/README.md +11 -1
 - data/Rakefile +2 -0
 - data/bench/compare.rb +17 -13
 - data/demo/Gemfile +3 -2
 - data/demo/Rakefile +6 -5
 - data/demo/app/workers/a_worker.rb +2 -0
 - data/demo/app/workers/b_worker.rb +2 -0
 - data/demo/app/workers/c_worker.rb +2 -1
 - data/demo/app/workers/fast_worker.rb +2 -0
 - data/demo/app/workers/slow_worker.rb +2 -0
 - data/demo/config/application.rb +3 -1
 - data/demo/config/boot.rb +4 -2
 - data/demo/config/environment.rb +3 -1
 - data/demo/config/environments/development.rb +2 -0
 - data/docker-compose.dev.yml +13 -0
 - data/gemfiles/sidekiq_6.0.gemfile.lock +3 -4
 - data/gemfiles/sidekiq_6.1.gemfile.lock +3 -4
 - data/gemfiles/sidekiq_6.2.gemfile.lock +3 -4
 - data/gemfiles/sidekiq_6.3.gemfile.lock +3 -4
 - data/gemfiles/sidekiq_6.4.gemfile.lock +3 -4
 - data/gemfiles/sidekiq_6.5.gemfile.lock +3 -4
 - data/gemfiles/sidekiq_7.0.gemfile +7 -0
 - data/gemfiles/sidekiq_7.0.gemfile.lock +58 -0
 - data/gemfiles/sidekiq_master.gemfile.lock +3 -4
 - data/lib/sidekiq/extensions/manager.rb +21 -13
 - data/lib/sidekiq/extensions/queue.rb +16 -13
 - data/lib/sidekiq/limit_fetch/global/monitor.rb +64 -53
 - data/lib/sidekiq/limit_fetch/global/selector.rb +49 -40
 - data/lib/sidekiq/limit_fetch/global/semaphore.rb +130 -123
 - data/lib/sidekiq/limit_fetch/instances.rb +22 -16
 - data/lib/sidekiq/limit_fetch/queues.rb +165 -124
 - data/lib/sidekiq/limit_fetch/unit_of_work.rb +26 -22
 - data/lib/sidekiq/limit_fetch.rb +73 -54
 - data/lib/sidekiq-limit_fetch.rb +2 -0
 - data/sidekiq-limit_fetch.gemspec +20 -13
 - data/spec/sidekiq/extensions/manager_spec.rb +19 -0
 - data/spec/sidekiq/extensions/queue_spec.rb +2 -0
 - data/spec/sidekiq/limit_fetch/global/monitor_spec.rb +86 -5
 - data/spec/sidekiq/limit_fetch/queues_spec.rb +34 -18
 - data/spec/sidekiq/limit_fetch/semaphore_spec.rb +2 -0
 - data/spec/sidekiq/limit_fetch_spec.rb +14 -4
 - data/spec/spec_helper.rb +15 -4
 - metadata +34 -21
 
| 
         @@ -1,159 +1,200 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Sidekiq
         
     | 
| 
      
 4 
     | 
    
         
            +
              module LimitFetch
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Queues
         
     | 
| 
      
 6 
     | 
    
         
            +
                  extend self
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  THREAD_KEY = :acquired_queues
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  # rubocop:disable Metrics/AbcSize
         
     | 
| 
      
 11 
     | 
    
         
            +
                  # rubocop:disable Metrics/CyclomaticComplexity
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # rubocop:disable Metrics/MethodLength
         
     | 
| 
      
 13 
     | 
    
         
            +
                  # rubocop:disable Metrics/PerceivedComplexity
         
     | 
| 
      
 14 
     | 
    
         
            +
                  def start(capsule_or_options)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    config = Sidekiq::LimitFetch.post_7? ? capsule_or_options.config : capsule_or_options
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    @queues = config[:queues].map do |queue|
         
     | 
| 
      
 18 
     | 
    
         
            +
                      if queue.is_a? Array
         
     | 
| 
      
 19 
     | 
    
         
            +
                        queue.first
         
     | 
| 
      
 20 
     | 
    
         
            +
                      else
         
     | 
| 
      
 21 
     | 
    
         
            +
                        queue
         
     | 
| 
      
 22 
     | 
    
         
            +
                      end
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end.uniq
         
     | 
| 
      
 24 
     | 
    
         
            +
                    @startup_queues = @queues.dup
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                    if config[:dynamic].is_a? Hash
         
     | 
| 
      
 27 
     | 
    
         
            +
                      @dynamic         = true
         
     | 
| 
      
 28 
     | 
    
         
            +
                      @dynamic_exclude = config[:dynamic][:exclude] || []
         
     | 
| 
      
 29 
     | 
    
         
            +
                    else
         
     | 
| 
      
 30 
     | 
    
         
            +
                      @dynamic = config[:dynamic]
         
     | 
| 
      
 31 
     | 
    
         
            +
                      @dynamic_exclude = []
         
     | 
| 
      
 32 
     | 
    
         
            +
                    end
         
     | 
| 
       3 
33 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
                    @limits         = config[:limits] || {}
         
     | 
| 
      
 35 
     | 
    
         
            +
                    @process_limits = config[:process_limits] || {}
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @blocks         = config[:blocking] || []
         
     | 
| 
       5 
37 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                @queues         = options[:queues]
         
     | 
| 
       8 
     | 
    
         
            -
                @startup_queues = options[:queues].dup
         
     | 
| 
       9 
     | 
    
         
            -
                @dynamic        = options[:dynamic]
         
     | 
| 
      
 38 
     | 
    
         
            +
                    config[:strict] ? strict_order! : weighted_order!
         
     | 
| 
       10 
39 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 40 
     | 
    
         
            +
                    apply_process_limit_to_queues
         
     | 
| 
      
 41 
     | 
    
         
            +
                    apply_limit_to_queues
         
     | 
| 
      
 42 
     | 
    
         
            +
                    apply_blocks_to_queues
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                  # rubocop:enable Metrics/AbcSize
         
     | 
| 
      
 45 
     | 
    
         
            +
                  # rubocop:enable Metrics/CyclomaticComplexity
         
     | 
| 
      
 46 
     | 
    
         
            +
                  # rubocop:enable Metrics/MethodLength
         
     | 
| 
      
 47 
     | 
    
         
            +
                  # rubocop:enable Metrics/PerceivedComplexity
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  def acquire
         
     | 
| 
      
 50 
     | 
    
         
            +
                    queues = saved
         
     | 
| 
      
 51 
     | 
    
         
            +
                    queues ||= Sidekiq::LimitFetch.redis_retryable do
         
     | 
| 
      
 52 
     | 
    
         
            +
                      selector.acquire(ordered_queues, namespace)
         
     | 
| 
      
 53 
     | 
    
         
            +
                    end
         
     | 
| 
      
 54 
     | 
    
         
            +
                    save queues
         
     | 
| 
      
 55 
     | 
    
         
            +
                    queues.map { |it| "queue:#{it}" }
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
       14 
57 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
                  def release_except(full_name)
         
     | 
| 
      
 59 
     | 
    
         
            +
                    queues = restore
         
     | 
| 
      
 60 
     | 
    
         
            +
                    queues.delete full_name[/queue:(.*)/, 1] if full_name
         
     | 
| 
      
 61 
     | 
    
         
            +
                    Sidekiq::LimitFetch.redis_retryable do
         
     | 
| 
      
 62 
     | 
    
         
            +
                      selector.release queues, namespace
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end
         
     | 
| 
       16 
65 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
                  def dynamic?
         
     | 
| 
      
 67 
     | 
    
         
            +
                    @dynamic
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
       21 
69 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  selector.acquire(ordered_queues, namespace)
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
                save queues
         
     | 
| 
       28 
     | 
    
         
            -
                queues.map { |it| "queue:#{it}" }
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
                  def startup_queue?(queue)
         
     | 
| 
      
 71 
     | 
    
         
            +
                    @startup_queues.include?(queue)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
       30 
73 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                Sidekiq::LimitFetch.redis_retryable do
         
     | 
| 
       35 
     | 
    
         
            -
                  selector.release queues, namespace
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
                  def dynamic_exclude
         
     | 
| 
      
 75 
     | 
    
         
            +
                    @dynamic_exclude
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
       38 
77 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
                  def add(queues)
         
     | 
| 
      
 79 
     | 
    
         
            +
                    return unless queues
         
     | 
| 
       42 
80 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
                    queues.each do |queue|
         
     | 
| 
      
 82 
     | 
    
         
            +
                      next if @queues.include? queue
         
     | 
| 
       46 
83 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                       
     | 
| 
       53 
     | 
    
         
            -
                      apply_limit_to_queue(queue)
         
     | 
| 
      
 84 
     | 
    
         
            +
                      if startup_queue?(queue)
         
     | 
| 
      
 85 
     | 
    
         
            +
                        apply_process_limit_to_queue(queue)
         
     | 
| 
      
 86 
     | 
    
         
            +
                        apply_limit_to_queue(queue)
         
     | 
| 
      
 87 
     | 
    
         
            +
                      end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                      @queues.push queue
         
     | 
| 
       54 
90 
     | 
    
         
             
                    end
         
     | 
| 
      
 91 
     | 
    
         
            +
                  end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                  def remove(queues)
         
     | 
| 
      
 94 
     | 
    
         
            +
                    return unless queues
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                    queues.each do |queue|
         
     | 
| 
      
 97 
     | 
    
         
            +
                      next unless @queues.include? queue
         
     | 
| 
       55 
98 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 99 
     | 
    
         
            +
                      clear_limits_for_queue(queue)
         
     | 
| 
      
 100 
     | 
    
         
            +
                      @queues.delete queue
         
     | 
| 
      
 101 
     | 
    
         
            +
                      Sidekiq::Queue.delete_instance(queue)
         
     | 
| 
      
 102 
     | 
    
         
            +
                    end
         
     | 
| 
       57 
103 
     | 
    
         
             
                  end
         
     | 
| 
       58 
     | 
    
         
            -
                end
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
104 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                  if @queues.include? queue
         
     | 
| 
       65 
     | 
    
         
            -
                    clear_limits_for_queue(queue)
         
     | 
| 
       66 
     | 
    
         
            -
                    @queues.delete queue
         
     | 
| 
       67 
     | 
    
         
            -
                    Sidekiq::Queue.delete_instance(queue)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  def handle(queues)
         
     | 
| 
      
 106 
     | 
    
         
            +
                    add(queues - @queues)
         
     | 
| 
      
 107 
     | 
    
         
            +
                    remove(@queues - queues)
         
     | 
| 
       68 
108 
     | 
    
         
             
                  end
         
     | 
| 
       69 
     | 
    
         
            -
                end
         
     | 
| 
       70 
     | 
    
         
            -
              end
         
     | 
| 
       71 
109 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
      
 110 
     | 
    
         
            +
                  # rubocop:disable Lint/NestedMethodDefinition
         
     | 
| 
      
 111 
     | 
    
         
            +
                  def strict_order!
         
     | 
| 
      
 112 
     | 
    
         
            +
                    @queues.uniq!
         
     | 
| 
      
 113 
     | 
    
         
            +
                    def ordered_queues
         
     | 
| 
      
 114 
     | 
    
         
            +
                      @queues
         
     | 
| 
      
 115 
     | 
    
         
            +
                    end
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
       76 
117 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
      
 118 
     | 
    
         
            +
                  def weighted_order!
         
     | 
| 
      
 119 
     | 
    
         
            +
                    def ordered_queues
         
     | 
| 
      
 120 
     | 
    
         
            +
                      @queues.shuffle.uniq
         
     | 
| 
      
 121 
     | 
    
         
            +
                    end
         
     | 
| 
      
 122 
     | 
    
         
            +
                  end
         
     | 
| 
      
 123 
     | 
    
         
            +
                  # rubocop:enable Lint/NestedMethodDefinition
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                  def namespace
         
     | 
| 
      
 126 
     | 
    
         
            +
                    @namespace ||= Sidekiq.redis do |it|
         
     | 
| 
      
 127 
     | 
    
         
            +
                      if it.respond_to?(:namespace) && it.namespace
         
     | 
| 
      
 128 
     | 
    
         
            +
                        "#{it.namespace}:"
         
     | 
| 
      
 129 
     | 
    
         
            +
                      else
         
     | 
| 
      
 130 
     | 
    
         
            +
                        ''
         
     | 
| 
      
 131 
     | 
    
         
            +
                      end
         
     | 
| 
      
 132 
     | 
    
         
            +
                    end
         
     | 
| 
      
 133 
     | 
    
         
            +
                  end
         
     | 
| 
       81 
134 
     | 
    
         | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                def ordered_queues; @queues.shuffle.uniq end
         
     | 
| 
       84 
     | 
    
         
            -
              end
         
     | 
| 
      
 135 
     | 
    
         
            +
                  private
         
     | 
| 
       85 
136 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                     
     | 
| 
       90 
     | 
    
         
            -
                  else
         
     | 
| 
       91 
     | 
    
         
            -
                    ''
         
     | 
| 
      
 137 
     | 
    
         
            +
                  def apply_process_limit_to_queues
         
     | 
| 
      
 138 
     | 
    
         
            +
                    @queues.uniq.each do |queue_name|
         
     | 
| 
      
 139 
     | 
    
         
            +
                      apply_process_limit_to_queue(queue_name)
         
     | 
| 
      
 140 
     | 
    
         
            +
                    end
         
     | 
| 
       92 
141 
     | 
    
         
             
                  end
         
     | 
| 
       93 
     | 
    
         
            -
                end
         
     | 
| 
       94 
     | 
    
         
            -
              end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
              private
         
     | 
| 
       97 
142 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
              end
         
     | 
| 
      
 143 
     | 
    
         
            +
                  def apply_process_limit_to_queue(queue_name)
         
     | 
| 
      
 144 
     | 
    
         
            +
                    queue = Sidekiq::Queue[queue_name]
         
     | 
| 
      
 145 
     | 
    
         
            +
                    queue.process_limit = @process_limits[queue_name.to_s] || @process_limits[queue_name.to_sym]
         
     | 
| 
      
 146 
     | 
    
         
            +
                  end
         
     | 
| 
       103 
147 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
      
 148 
     | 
    
         
            +
                  def apply_limit_to_queues
         
     | 
| 
      
 149 
     | 
    
         
            +
                    @queues.uniq.each do |queue_name|
         
     | 
| 
      
 150 
     | 
    
         
            +
                      apply_limit_to_queue(queue_name)
         
     | 
| 
      
 151 
     | 
    
         
            +
                    end
         
     | 
| 
      
 152 
     | 
    
         
            +
                  end
         
     | 
| 
       108 
153 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
                  apply_limit_to_queue(queue_name)
         
     | 
| 
       112 
     | 
    
         
            -
                end
         
     | 
| 
       113 
     | 
    
         
            -
              end
         
     | 
| 
      
 154 
     | 
    
         
            +
                  def apply_limit_to_queue(queue_name)
         
     | 
| 
      
 155 
     | 
    
         
            +
                    queue = Sidekiq::Queue[queue_name]
         
     | 
| 
       114 
156 
     | 
    
         | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
                queue = Sidekiq::Queue[queue_name]
         
     | 
| 
      
 157 
     | 
    
         
            +
                    return if queue.limit_changed?
         
     | 
| 
       117 
158 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                   
     | 
| 
       120 
     | 
    
         
            -
                end
         
     | 
| 
       121 
     | 
    
         
            -
              end
         
     | 
| 
      
 159 
     | 
    
         
            +
                    queue.limit = @limits[queue_name.to_s] || @limits[queue_name.to_sym]
         
     | 
| 
      
 160 
     | 
    
         
            +
                  end
         
     | 
| 
       122 
161 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
      
 162 
     | 
    
         
            +
                  def apply_blocks_to_queues
         
     | 
| 
      
 163 
     | 
    
         
            +
                    @queues.uniq.each do |queue_name|
         
     | 
| 
      
 164 
     | 
    
         
            +
                      Sidekiq::Queue[queue_name].unblock
         
     | 
| 
      
 165 
     | 
    
         
            +
                    end
         
     | 
| 
       127 
166 
     | 
    
         | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
      
 167 
     | 
    
         
            +
                    @blocks.to_a.each do |it|
         
     | 
| 
      
 168 
     | 
    
         
            +
                      if it.is_a? Array
         
     | 
| 
      
 169 
     | 
    
         
            +
                        it.each { |name| Sidekiq::Queue[name].block_except it }
         
     | 
| 
      
 170 
     | 
    
         
            +
                      else
         
     | 
| 
      
 171 
     | 
    
         
            +
                        Sidekiq::Queue[it].block
         
     | 
| 
      
 172 
     | 
    
         
            +
                      end
         
     | 
| 
      
 173 
     | 
    
         
            +
                    end
         
     | 
| 
       133 
174 
     | 
    
         
             
                  end
         
     | 
| 
       134 
     | 
    
         
            -
                end
         
     | 
| 
       135 
     | 
    
         
            -
              end
         
     | 
| 
       136 
175 
     | 
    
         | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
      
 176 
     | 
    
         
            +
                  def clear_limits_for_queue(queue_name)
         
     | 
| 
      
 177 
     | 
    
         
            +
                    queue = Sidekiq::Queue[queue_name]
         
     | 
| 
      
 178 
     | 
    
         
            +
                    queue.clear_limits
         
     | 
| 
      
 179 
     | 
    
         
            +
                  end
         
     | 
| 
       141 
180 
     | 
    
         | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
      
 181 
     | 
    
         
            +
                  def selector
         
     | 
| 
      
 182 
     | 
    
         
            +
                    Sidekiq::LimitFetch::Global::Selector
         
     | 
| 
      
 183 
     | 
    
         
            +
                  end
         
     | 
| 
       145 
184 
     | 
    
         | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
      
 185 
     | 
    
         
            +
                  def saved
         
     | 
| 
      
 186 
     | 
    
         
            +
                    Thread.current[THREAD_KEY]
         
     | 
| 
      
 187 
     | 
    
         
            +
                  end
         
     | 
| 
       149 
188 
     | 
    
         | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
      
 189 
     | 
    
         
            +
                  def save(queues)
         
     | 
| 
      
 190 
     | 
    
         
            +
                    Thread.current[THREAD_KEY] = queues
         
     | 
| 
      
 191 
     | 
    
         
            +
                  end
         
     | 
| 
       153 
192 
     | 
    
         | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
       157 
     | 
    
         
            -
             
     | 
| 
      
 193 
     | 
    
         
            +
                  def restore
         
     | 
| 
      
 194 
     | 
    
         
            +
                    saved || []
         
     | 
| 
      
 195 
     | 
    
         
            +
                  ensure
         
     | 
| 
      
 196 
     | 
    
         
            +
                    save nil
         
     | 
| 
      
 197 
     | 
    
         
            +
                  end
         
     | 
| 
      
 198 
     | 
    
         
            +
                end
         
     | 
| 
       158 
199 
     | 
    
         
             
              end
         
     | 
| 
       159 
200 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,32 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Sidekiq
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
       4 
     | 
    
         
            -
                   
     | 
| 
       5 
     | 
    
         
            -
                     
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                     
     | 
| 
      
 4 
     | 
    
         
            +
              module LimitFetch
         
     | 
| 
      
 5 
     | 
    
         
            +
                class UnitOfWork < BasicFetch::UnitOfWork
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def initialize(queue, job)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    if post_6_5?
         
     | 
| 
      
 8 
     | 
    
         
            +
                      super(queue, job, Sidekiq)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    else
         
     | 
| 
      
 10 
     | 
    
         
            +
                      super
         
     | 
| 
      
 11 
     | 
    
         
            +
                    end
         
     | 
| 
      
 12 
     | 
    
         
            +
                    redis_retryable { Queue[queue_name].increase_busy }
         
     | 
| 
       8 
13 
     | 
    
         
             
                  end
         
     | 
| 
       9 
     | 
    
         
            -
                  redis_retryable { Queue[queue_name].increase_busy }
         
     | 
| 
       10 
     | 
    
         
            -
                end
         
     | 
| 
       11 
14 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def acknowledge
         
     | 
| 
      
 16 
     | 
    
         
            +
                    redis_retryable { Queue[queue_name].decrease_busy }
         
     | 
| 
      
 17 
     | 
    
         
            +
                    redis_retryable { Queue[queue_name].release }
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
       16 
19 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def requeue
         
     | 
| 
      
 21 
     | 
    
         
            +
                    super
         
     | 
| 
      
 22 
     | 
    
         
            +
                    acknowledge
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
       21 
24 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
                  private
         
     | 
| 
       23 
26 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
                  def post_6_5?
         
     | 
| 
      
 28 
     | 
    
         
            +
                    Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
       27 
30 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def redis_retryable(&block)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    Sidekiq::LimitFetch.redis_retryable(&block)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
       30 
34 
     | 
    
         
             
                end
         
     | 
| 
       31 
35 
     | 
    
         
             
              end
         
     | 
| 
       32 
36 
     | 
    
         
             
            end
         
     | 
    
        data/lib/sidekiq/limit_fetch.rb
    CHANGED
    
    | 
         @@ -1,76 +1,95 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'forwardable'
         
     | 
| 
       2 
4 
     | 
    
         
             
            require 'sidekiq'
         
     | 
| 
       3 
5 
     | 
    
         
             
            require 'sidekiq/manager'
         
     | 
| 
       4 
6 
     | 
    
         
             
            require 'sidekiq/api'
         
     | 
| 
       5 
7 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            module Sidekiq 
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
      
 8 
     | 
    
         
            +
            module Sidekiq
         
     | 
| 
      
 9 
     | 
    
         
            +
              module LimitFetch
         
     | 
| 
      
 10 
     | 
    
         
            +
                autoload :UnitOfWork, 'sidekiq/limit_fetch/unit_of_work'
         
     | 
| 
       8 
11 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
                require_relative 'limit_fetch/instances'
         
     | 
| 
      
 13 
     | 
    
         
            +
                require_relative 'limit_fetch/queues'
         
     | 
| 
      
 14 
     | 
    
         
            +
                require_relative 'limit_fetch/global/semaphore'
         
     | 
| 
      
 15 
     | 
    
         
            +
                require_relative 'limit_fetch/global/selector'
         
     | 
| 
      
 16 
     | 
    
         
            +
                require_relative 'limit_fetch/global/monitor'
         
     | 
| 
      
 17 
     | 
    
         
            +
                require_relative 'extensions/queue'
         
     | 
| 
      
 18 
     | 
    
         
            +
                require_relative 'extensions/manager'
         
     | 
| 
       16 
19 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
                TIMEOUT = Sidekiq::BasicFetch::TIMEOUT
         
     | 
| 
       18 
21 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
                extend self
         
     | 
| 
       20 
23 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                def post_7?
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @post_7 ||= Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('7.0.0')
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
       24 
27 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                 
     | 
| 
       28 
     | 
    
         
            -
                UnitOfWork.new(queue, job) if job
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
                def post_6_5?
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @post_6_5 ||= Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                 
     | 
| 
       33 
     | 
    
         
            -
                post_6_5? ? Sidekiq : Sidekiq.options
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
                RedisBaseConnectionError = post_7? ? RedisClient::ConnectionError : Redis::BaseConnectionError
         
     | 
| 
      
 33 
     | 
    
         
            +
                RedisCommandError = post_7? ? RedisClient::CommandError : Redis::CommandError
         
     | 
| 
       35 
34 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
              def bulk_requeue(*args)
         
     | 
| 
       39 
     | 
    
         
            -
                if Sidekiq::BasicFetch.respond_to?(:bulk_requeue) # < 6.1.0
         
     | 
| 
       40 
     | 
    
         
            -
                  Sidekiq::BasicFetch.bulk_requeue(*args)
         
     | 
| 
       41 
     | 
    
         
            -
                else # 6.1.0+
         
     | 
| 
       42 
     | 
    
         
            -
                  Sidekiq::BasicFetch.new(config).bulk_requeue(*args)
         
     | 
| 
      
 35 
     | 
    
         
            +
                def new(_)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  self
         
     | 
| 
       43 
37 
     | 
    
         
             
                end
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
38 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                 
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                 
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
                def retrieve_work
         
     | 
| 
      
 40 
     | 
    
         
            +
                  queue, job = redis_brpop(Queues.acquire)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  Queues.release_except(queue)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  UnitOfWork.new(queue, job) if job
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                def config
         
     | 
| 
      
 46 
     | 
    
         
            +
                  # Post 6.5, Sidekiq.options is deprecated and replaced with passing Sidekiq directly
         
     | 
| 
      
 47 
     | 
    
         
            +
                  post_6_5? ? Sidekiq : Sidekiq.options
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                # Backwards compatibility for sidekiq v6.1.0
         
     | 
| 
      
 51 
     | 
    
         
            +
                # @see https://github.com/mperham/sidekiq/pull/4602
         
     | 
| 
      
 52 
     | 
    
         
            +
                def bulk_requeue(*args)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  if Sidekiq::BasicFetch.respond_to?(:bulk_requeue) # < 6.1.0
         
     | 
| 
      
 54 
     | 
    
         
            +
                    Sidekiq::BasicFetch.bulk_requeue(*args)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  else # 6.1.0+
         
     | 
| 
      
 56 
     | 
    
         
            +
                    Sidekiq::BasicFetch.new(post_7? ? Sidekiq.default_configuration.default_capsule : config).bulk_requeue(*args)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                def redis_retryable
         
     | 
| 
      
 61 
     | 
    
         
            +
                  yield
         
     | 
| 
      
 62 
     | 
    
         
            +
                rescue RedisBaseConnectionError
         
     | 
| 
       55 
63 
     | 
    
         
             
                  sleep TIMEOUT
         
     | 
| 
       56 
64 
     | 
    
         
             
                  retry
         
     | 
| 
       57 
     | 
    
         
            -
                 
     | 
| 
       58 
     | 
    
         
            -
                   
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 65 
     | 
    
         
            +
                rescue RedisCommandError => e
         
     | 
| 
      
 66 
     | 
    
         
            +
                  # If Redis was restarted and is still loading its snapshot,
         
     | 
| 
      
 67 
     | 
    
         
            +
                  # then we should treat this as a temporary connection error too.
         
     | 
| 
      
 68 
     | 
    
         
            +
                  raise unless e.message =~ /^LOADING/
         
     | 
| 
       61 
69 
     | 
    
         | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
                  sleep TIMEOUT
         
     | 
| 
      
 71 
     | 
    
         
            +
                  retry
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
       63 
73 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                @post_6_5 ||= Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
         
     | 
| 
       66 
     | 
    
         
            -
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
                private
         
     | 
| 
       67 
75 
     | 
    
         | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                 
     | 
| 
       70 
     | 
    
         
            -
                   
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                   
     | 
| 
      
 76 
     | 
    
         
            +
                # rubocop:disable Metrics/MethodLength
         
     | 
| 
      
 77 
     | 
    
         
            +
                def redis_brpop(queues)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  if queues.empty?
         
     | 
| 
      
 79 
     | 
    
         
            +
                    sleep TIMEOUT  # there are no queues to handle, so lets sleep
         
     | 
| 
      
 80 
     | 
    
         
            +
                    []             # and return nothing
         
     | 
| 
      
 81 
     | 
    
         
            +
                  else
         
     | 
| 
      
 82 
     | 
    
         
            +
                    redis_retryable do
         
     | 
| 
      
 83 
     | 
    
         
            +
                      Sidekiq.redis do |it|
         
     | 
| 
      
 84 
     | 
    
         
            +
                        if post_7?
         
     | 
| 
      
 85 
     | 
    
         
            +
                          it.blocking_call(false, 'brpop', *queues, TIMEOUT)
         
     | 
| 
      
 86 
     | 
    
         
            +
                        else
         
     | 
| 
      
 87 
     | 
    
         
            +
                          it.brpop(*queues, timeout: TIMEOUT)
         
     | 
| 
      
 88 
     | 
    
         
            +
                        end
         
     | 
| 
      
 89 
     | 
    
         
            +
                      end
         
     | 
| 
      
 90 
     | 
    
         
            +
                    end
         
     | 
| 
      
 91 
     | 
    
         
            +
                  end
         
     | 
| 
       74 
92 
     | 
    
         
             
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
                # rubocop:enable Metrics/MethodLength
         
     | 
| 
       75 
94 
     | 
    
         
             
              end
         
     | 
| 
       76 
95 
     | 
    
         
             
            end
         
     | 
    
        data/lib/sidekiq-limit_fetch.rb
    CHANGED
    
    
    
        data/sidekiq-limit_fetch.gemspec
    CHANGED
    
    | 
         @@ -1,25 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'English'
         
     | 
| 
       1 
4 
     | 
    
         
             
            Gem::Specification.new do |gem|
         
     | 
| 
       2 
5 
     | 
    
         
             
              gem.name          = 'sidekiq-limit_fetch'
         
     | 
| 
       3 
     | 
    
         
            -
              gem.version       = '4. 
     | 
| 
      
 6 
     | 
    
         
            +
              gem.version       = '4.4.1'
         
     | 
| 
       4 
7 
     | 
    
         
             
              gem.license       = 'MIT'
         
     | 
| 
       5 
     | 
    
         
            -
              gem.authors       = ['Dean Perry' 
     | 
| 
      
 8 
     | 
    
         
            +
              gem.authors       = ['Dean Perry']
         
     | 
| 
       6 
9 
     | 
    
         
             
              gem.email         = 'dean@deanpcmad.com'
         
     | 
| 
       7 
10 
     | 
    
         
             
              gem.summary       = 'Sidekiq strategy to support queue limits'
         
     | 
| 
       8 
11 
     | 
    
         
             
              gem.homepage      = 'https://github.com/deanpcmad/sidekiq-limit_fetch'
         
     | 
| 
       9 
     | 
    
         
            -
              gem.description   =  
     | 
| 
      
 12 
     | 
    
         
            +
              gem.description   = 'Sidekiq strategy to restrict number of workers which are able to run specified ' \
         
     | 
| 
      
 13 
     | 
    
         
            +
                                  'queues simultaneously.'
         
     | 
| 
       10 
14 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
              gem.metadata[ 
     | 
| 
       12 
     | 
    
         
            -
              gem.metadata[ 
     | 
| 
       13 
     | 
    
         
            -
              gem.metadata[ 
     | 
| 
      
 15 
     | 
    
         
            +
              gem.metadata['homepage_uri'] = gem.homepage
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem.metadata['source_code_uri'] = 'https://github.com/deanpcmad/sidekiq-limit_fetch'
         
     | 
| 
      
 17 
     | 
    
         
            +
              gem.metadata['changelog_uri'] = 'https://github.com/deanpcmad/sidekiq-limit_fetch/blob/master/CHANGELOG.md'
         
     | 
| 
      
 18 
     | 
    
         
            +
              gem.metadata['rubygems_mfa_required'] = 'true'
         
     | 
| 
       14 
19 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
              gem.files         = `git ls-files`.split( 
     | 
| 
       16 
     | 
    
         
            -
              gem. 
     | 
| 
       17 
     | 
    
         
            -
              gem.require_paths = %w(lib)
         
     | 
| 
      
 20 
     | 
    
         
            +
              gem.files         = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
         
     | 
| 
      
 21 
     | 
    
         
            +
              gem.require_paths = %w[lib]
         
     | 
| 
       18 
22 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
              gem. 
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              gem. 
     | 
| 
      
 23 
     | 
    
         
            +
              gem.required_ruby_version = '>= 2.7.0'
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              gem.add_dependency 'sidekiq', '>= 6'
         
     | 
| 
       22 
26 
     | 
    
         
             
              gem.add_development_dependency 'appraisal'
         
     | 
| 
       23 
     | 
    
         
            -
              gem.add_development_dependency 'rspec'
         
     | 
| 
       24 
27 
     | 
    
         
             
              gem.add_development_dependency 'rake'
         
     | 
| 
      
 28 
     | 
    
         
            +
              gem.add_development_dependency 'redis-namespace', '~> 1.5', '>= 1.5.2'
         
     | 
| 
      
 29 
     | 
    
         
            +
              gem.add_development_dependency 'rspec'
         
     | 
| 
      
 30 
     | 
    
         
            +
              gem.add_development_dependency 'rubocop'
         
     | 
| 
      
 31 
     | 
    
         
            +
              gem.add_development_dependency 'simplecov'
         
     | 
| 
       25 
32 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            RSpec.describe Sidekiq::Manager do
         
     | 
| 
      
 4 
     | 
    
         
            +
              let(:capsule_or_options) do
         
     | 
| 
      
 5 
     | 
    
         
            +
                if Sidekiq::LimitFetch.post_7?
         
     | 
| 
      
 6 
     | 
    
         
            +
                  Sidekiq.default_configuration.default_capsule
         
     | 
| 
      
 7 
     | 
    
         
            +
                elsif Sidekiq::LimitFetch.post_6_5?
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Sidekiq
         
     | 
| 
      
 9 
     | 
    
         
            +
                else
         
     | 
| 
      
 10 
     | 
    
         
            +
                  Sidekiq.options
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              it 'can be instantiated' do
         
     | 
| 
      
 15 
     | 
    
         
            +
                expect(described_class).to be < Sidekiq::Manager::InitLimitFetch
         
     | 
| 
      
 16 
     | 
    
         
            +
                manager = described_class.new(capsule_or_options)
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(manager).to respond_to(:start)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     |