Module: Resque::Plugins::RetryOnFail
- Includes:
- Retried
- Defined in:
- lib/resque/plugins/retry_on_fail.rb
Overview
If you want your job to retry when an exception is encountered, extend this module. Override retried_exceptions
to return an array of the exceptions that are ok to retry on. There are no defaults.
Instance Method Summary collapse
-
#on_failure_retry_on_fail(e, *args) ⇒ Object
Use resque’s failure hook.
-
#retried_exceptions ⇒ Object
Override in your subclass to control how long to wait before re-queueing the job when a lock is encountered.
-
#retried_on_exception?(ex) ⇒ Boolean
Convenience method to test whether your class will retry on a given exception type.
Methods included from Retried
#args_for_try_again, #seconds_until_retry, #try_again
Instance Method Details
#on_failure_retry_on_fail(e, *args) ⇒ Object
Use resque’s failure hook.
25 26 27 |
# File 'lib/resque/plugins/retry_on_fail.rb', line 25 def on_failure_retry_on_fail(e, *args) try_again(*args) if retried_on_exception?(e.class) end |
#retried_exceptions ⇒ Object
Override in your subclass to control how long to wait before re-queueing the job when a lock is encountered. Note that the job will block other jobs while this wait occurs. Return nil to perform no delay.
20 21 22 |
# File 'lib/resque/plugins/retry_on_fail.rb', line 20 def retried_exceptions [] end |
#retried_on_exception?(ex) ⇒ Boolean
Convenience method to test whether your class will retry on a given exception type.
12 13 14 |
# File 'lib/resque/plugins/retry_on_fail.rb', line 12 def retried_on_exception?(ex) !! retried_exceptions.any? { |e| e >= ex } end |