lib/good_job/active_job_job.rb
# Discard a job so that it will not be executed further.
# This action will add a {DiscardJobError} to the job's {Execution} and mark it as finished.
# @return [void]
Discard a job so that it will not be executed further.
This action will add a {DiscardJobError} to the job's {Execution} and mark it as finished.
Discard a job so that it will not be executed further . This action will add a { DiscardJobError } to the job ' s { Execution } and mark it as finished .
def discard_job(message)
      with_advisory_lock do
        execution = head_execution(reload: true)
        active_job = execution.active_job
        raise ActionForStateMismatchError if execution.finished_at.present?
        job_error = GoodJob::ActiveJobJob::DiscardJobError.new(message)
        update_execution = proc do
          execution.update(
            finished_at: Time.current,
            error: [job_error.class, GoodJob::Execution::ERROR_MESSAGE_SEPARATOR, job_error.message].join
          )
        end
        if active_job.respond_to?(:instrument)
          active_job.send :instrument, :discard, error: job_error, &update_execution
        else
          update_execution.call
        end
      end
    end
def discard_job ( message ) with_advisory_lock do execution = head_execution ( reload : true ) active_job = execution . active_job raise ActionForStateMismatchError if execution . finished_at . present? job_error = GoodJob :: ActiveJobJob :: DiscardJobError . new ( message ) update_execution = proc do execution . update ( finished_at : Time . current , error : [ job_error . class , GoodJob :: Execution :: ERROR_MESSAGE_SEPARATOR , job_error . message ] . join ) end if active_job . respond_to? ( :instrument ) active_job . send :instrument , :discard , error : job_error , & update_execution else update_execution . call end end end
Discard a job so that it will not be executed further.
Discard a job so that it will not be executed further .
None
void
message