england / sidekiq-queue-pause

Sidekiq extension to pause queue processing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Sidekiq extension to pause queue processing

License:MIT License


Languages

Language:Ruby 100.0%