akira/exq

Fail jobs on non-ok return value?

Opened this issue · 1 comments

Hello :)

It would have been nice to be able to fail jobs "normally" like:

def perform()
  # ...
  # Trying to do something and get a known error
  Exq.fail_job("Error while trying to do a thing: #{error}")
end

Id would be cleaner than just crashing :)

What do you think?

Right now to reach this behavior I use code like this:

def fail_job(message) do
    Logger.error(message)

    # in order not to use exception to retry job,
    # send :normal exit signal to finish as failed
    exit(:normal)
end