Module: RocketJob::Plugins::Retry
- Extended by:
- ActiveSupport::Concern
- Included in:
- Jobs::CopyFileJob, Jobs::OnDemandBatchJob, Jobs::OnDemandJob
- Defined in:
- lib/rocket_job/plugins/retry.rb
Overview
Automatically retry the job on failure.
Example:
class MyJob < RocketJob::Job
include RocketJob::Plugins::Retry
# Set the maximum number of times a job should be retried before giving up.
self.retry_limit = 3
def perform
puts "DONE"
end
end
# Queue the job for processing using the default cron_schedule specified above MyJob.create!
# Override the default retry_limit for a specific job instance. MyCronJob.create!(retry_limit: 10)
# Disable retries for this job instance. MyCronJob.create!(retry_limit: 0)
Instance Method Summary collapse
- #rocket_job_failure_count ⇒ Object
-
#rocket_job_retry_on_fail? ⇒ Boolean
Returns [true|false] whether this job should be retried on failure.
Instance Method Details
#rocket_job_failure_count ⇒ Object
50 51 52 |
# File 'lib/rocket_job/plugins/retry.rb', line 50 def rocket_job_failure_count failed_at_list.size end |
#rocket_job_retry_on_fail? ⇒ Boolean
Returns [true|false] whether this job should be retried on failure.
46 47 48 |
# File 'lib/rocket_job/plugins/retry.rb', line 46 def rocket_job_retry_on_fail? rocket_job_failure_count < retry_limit end |