Skip to content

Instantly share code, notes, and snippets.

@Alex-Karpov-878
Last active March 29, 2020 23:22
Show Gist options
  • Save Alex-Karpov-878/3da88e006b623cb1fd817b6f1214ec87 to your computer and use it in GitHub Desktop.
Save Alex-Karpov-878/3da88e006b623cb1fd817b6f1214ec87 to your computer and use it in GitHub Desktop.
Sidekiq api notes
rails c
require 'sidekiq/api'
Sidekiq::Queue.all
mailers = Sidekiq::Queue.new("mailers")
mailers.size
mails.each {|job| job.inspect }
mailers.each { |job| job.delete if job.jid == 'asdf' }
mailers.latency
mailers.find("asdf2")
mailers.clear
rs = Sidekiq::RetrySet.new
ds = Sidekiq::DeadSet.new
ps = Sidekiq::ProcessSet.new
ps.map {|ps| [ps['busy'], ps['hostname'], ps['pid']]}
ps.each(&:quiet!)
ps.each(&:stop!)
workers = Sidekiq::Workers.new
workers.size
workers.each {|process_id, thread_id, work| [process_id.inspect, thread_id.inspect, work.inspect, work['payload'].inspect]}
stats = Sidekiq::Stats.new
stats.failed
stats.queues
stats.enqueued
s = Sidekiq::Stats::History.new(2)
s.processed
s = Sidekiq::Stats::History.new(2, Date.prase('Oct 12, 2020'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment