I have resque tasks that need to delay after failure with exponential backoff. But sometimes the exponential backoff should be reset -- if the job makes progress towards its ultimate goal, the delay should be reset to very short, but if it's stuck failing, it should continue waiting. So the job will run, and if it fails, there are two different failure modes. In one failure mode, the job should be retried again very soon, but then start to backoff. In the other failure mode, the job should be delayed for longer (say 2x) than the delay before the previous attempt.
It seems like retry_criteria_check
should be able to do this, but I'm not sure how to integrate it with Resque::Plugins::ExponentialBackoff
. I'm presuming I'll communicate the different failure modes by throwing different exceptions, unless somebody can suggest a better way.
With that kind of logic, it would probably be simpler to change the job to accept a previous_attempt_delay, previous_attempt_failure and then calculate what the new retry should be within the job itself. Then do the back off by creating the new job to be performed at the calculated time (and pass on those 2 params).