Question

Say I have a worker class that looks like this:

class BuilderWorker
  include Sidekiq::Worker
  sidekiq_options retry: false

  def perform(order_id)
    if(order_id == 5)
      # How can I finish the job here? Say I want to finish it with a status of FAIL or COMPLETE.
    end
  end
end

I am looking for a way to finish a job from the Worker class, and when finished give it the status of FAILED. The finish should be quiet, (not raising an exception)

Was it helpful?

Solution

With Sidekiq there are only two job results:

  • success - a job returns from the perform method without error
  • failure - a job raises an error, going onto the retry queue to be retried in the future

Your complicated scenario is called application logic and Sidekiq cannot provide it. It is up to you to write that logic.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top