Module: Arj::Job
- Defined in:
- lib/arj/job.rb
Overview
Module prepended to the singleton class of ActiveJob::Base objects in order to override #perform_now.
ActiveJob assumes that a job is removed from the queue before it is executed, then re-enqueued on retry. Arj, on the other hand, prefers to only remove jobs from the queue upon completion, so as to avoid data loss.
To accomplish the desired behavior, we Arj must override ActiveJob::Base#perform_now to delete the job from the database iff it was not re-enqueued.
Instance Method Summary collapse
-
#perform_now ⇒ Object
Overrides Active::Job#perform_now to ensure that successful jobs are removed from the queue.
Instance Method Details
#perform_now ⇒ Object
Overrides Active::Job#perform_now to ensure that successful jobs are removed from the queue.
13 14 15 16 17 18 |
# File 'lib/arj/job.rb', line 13 def perform_now self.successfully_enqueued = false super ensure Arj.record_class.find(provider_job_id).destroy! unless successfully_enqueued? end |