Best way to find a job anywhere in Sidekiq

farski picture farski · Jun 14, 2013 · Viewed 15k times · Source

Is there an easy way to search through all of sidekiq (queues, retries, schedules, etc) for a specific job?

Currently I'm doing this:

if !Sidekiq::Queue.new("feeds").find {|j| j.args[0] == feed.id && j.args[1] == true }
  if !Sidekiq::RetrySet.new.find {|j| j.queue == 'feeds' && j.args[0] == feed.id && j.args[1] == true }
    if !Sidekiq::ScheduledSet.new.find {|j| j.queue == 'feeds' && j.args[0] == feed.id && j.args[1] == true }
      feed.sync
    end
  end
end

But given how large queues can get, there's a chance the job could move between sets during the iteration and get missed.

Answer

Utgarda picture Utgarda · Jul 31, 2013

Seems like you want to know your job's status at some moment after spawning it, also you keep its id. There are a couple of plugins exactly for that, they have similar functionality and virtually the same name:

Sidekiq::Status - I was its original author, now it's supported by more apt Ruby developers

SidekiqStatus - an alternative

[edit] the above may be outdated by now, just check Sidekiq's wiki to find queue/status management that suits you best: https://github.com/mperham/sidekiq/wiki/Related-Projects