Class: Resque::Failure::MultipleWithRetrySuppression
- Inherits:
-
Multiple
- Object
- Multiple
- Resque::Failure::MultipleWithRetrySuppression
- Includes:
- Helpers
- Defined in:
- lib/resque/failure/multiple_with_retry_suppression.rb
Overview
A multiple failure backend, with retry suppression.
For example: if you had a job that could retry 5 times, your failure backends are not notified unless the final retry attempt also fails.
Example:
require 'resque-retry'
require 'resque/failure/redis'
Resque::Failure::MultipleWithRetrySuppression.classes = [Resque::Failure::Redis]
Resque::Failure.backend = Resque::Failure::MultipleWithRetrySuppression
Defined Under Namespace
Modules: CleanupHooks
Class Method Summary collapse
-
.failure_key(retry_key) ⇒ Object
Expose this for the hook’s use.
Instance Method Summary collapse
-
#save ⇒ Object
Called when the job fails.
Class Method Details
.failure_key(retry_key) ⇒ Object
Expose this for the hook’s use.
63 64 65 |
# File 'lib/resque/failure/multiple_with_retry_suppression.rb', line 63 def self.failure_key(retry_key) 'failure_' + retry_key end |
Instance Method Details
#save ⇒ Object
Called when the job fails.
If the job will retry, suppress the failure from the other backends. Store the lastest failure information in redis, used by the web interface.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/resque/failure/multiple_with_retry_suppression.rb', line 38 def save unless retryable? && cleanup_retry_failure_log! super else data = { :failed_at => Time.now.strftime("%Y/%m/%d %H:%M:%S"), :payload => payload, :exception => exception.class.to_s, :error => exception.to_s, :backtrace => Array(exception.backtrace), :worker => worker.to_s, :queue => queue } # Register cleanup hooks. unless klass.respond_to?(:after_perform_retry_failure_cleanup) klass.send(:extend, CleanupHooks) end redis[failure_key] = Resque.encode(data) end end |