A long-lived project that still receives updates
Let's you pause/unpause individual sidekiq queues.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
 Dependencies

Development

Runtime

>= 6.0, < 7.0
 Project Readme

Sidekiq::QueuePause

This gem adds a .pause functionality to Sidekiq queues. Sidekiq Pro has this feature, so please consider upgrading if you can.

Usage

Initializer:

Sidekiq.configure_server do |config|
  Sidekiq.options[:fetch] = Sidekiq::QueuePause::PausingFetch.new(Sidekiq.options)

  # Optionally, you may set some unique key identifying the
  # Sidekiq process you want to control. This (server) process will
  # only be paused/unpaused when the function gets called with
  # the corresponding key. See below.
  Sidekiq::QueuePause.process_key = 'foo'

  # You may also pass in a Proc which is then evaluated when needed.
  Sidekiq::QueuePause.process_key { SomeClass.some_method }

  # Optionally, you may configure the sleep period (in seconds) after the
  # queue lock has been checked. By default, the fetcher will sleep for
  # Sidekiq::Fetcher::TIMEOUT, i.e. the same time that the redis fetch
  # command may take.
  Sidekiq::QueuePause.retry_after = 5
end

Pausing a queue:

Sidekiq::QueuePause.pause(:example)
# With process key:
Sidekiq::QueuePause.pause(:example, 'foo')
# On a queue object:
example = Sidekiq::Queue.new(:example)
example.pause
# On a queue object with process key:
example.pause('foo')

Unpause:

Sidekiq::QueuePause.unpause(:example)

etc.

Getting pause status:

Sidekiq::QueuePause.paused?(:example)
# => true/false

etc.

Unpause all queues/processes:

Sidekiq::QueuePause.unpause_all

License

The gem is licensed under the MIT-License.