Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I put my resque-retry failure backend code?

The resque-retry gem's README discusses changing the failure backend implementation when implementing.

MultipleWithRetrySuppression is a multiple failure backend, with retry suppression.

Here's an example, using the Redis failure backend:

require 'resque-retry'
require 'resque/failure/redis'

# require your jobs & application code.

Resque::Failure::MultipleWithRetrySuppression.classes = [Resque::Failure::Redis]
Resque::Failure.backend = Resque::Failure::MultipleWithRetrySuppression

If a job fails, but can and will retry, the failure details wont be logged in the Redis failed queue (visible via resque-web).

If the job fails, but can't or won't retry, the failure will be logged in the Redis failed queue, like a normal failure (without retry) would.

I'm not sure where in my Rails app that code should go. Should I just place it into any random initializer file, e.g. config/initializers/resque.rb? Or is there some other place in my app where it should go? The documentation is not clear.

like image 508
Matt Huggins Avatar asked Oct 08 '22 03:10

Matt Huggins


1 Answers

Looks like an initializer is the best bet. Accepting this as the best answer unless someone comes along with a better suggestion.

like image 129
Matt Huggins Avatar answered Oct 12 '22 11:10

Matt Huggins