Skip to content

Instantly share code, notes, and snippets.

@andreaseriksson
Last active January 7, 2016 08:49
Show Gist options
  • Save andreaseriksson/41f16f832dd6ec34d168 to your computer and use it in GitHub Desktop.
Save andreaseriksson/41f16f832dd6ec34d168 to your computer and use it in GitHub Desktop.
require 'sidekiq/api'
# get a handle to the default queue
default_queue = Sidekiq::Queue.new
# clear the queue
Sidekiq::Queue.new.clear
# get a handle to the mailer queue
mailer_queue = Sidekiq::Queue.new("mailer")
# How many jobs are in the default queue?
default_queue.size # => 1001
# How many jobs are in the mailer queue?
mailer_queue.size # => 50
#Deletes all Jobs in a Queue, by removing the queue.
default_queue.clear
stats = Sidekiq::Stats.new
# Get the number of jobs that have been processed.
stats.processed # => 100
# Get the number of jobs that have failed.
stats.failed # => 3
# Get the queues with name and number enqueued.
stats.queues # => { "default" => 1001, "email" => 50 }
#Gets the number of jobs enqueued in all queues (does NOT include retries and scheduled jobs).
stats.enqueued # => 1051
rs = Sidekiq::RetrySet.new
rs.size
rs.clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment