Set callbacks for when a job run finishes fully.
When working with workflow jobs that make use of the awaits
feature for a step, it is important to remember that the after_perform
callback will be called as soon as the first awaits
step has enqueued job, and not when the entire job run has finished. AcidicJob
allows the perform
method to finish so that the queue for the workflow job is cleared to pick up new work while the awaits
jobs are running. AcidicJob
will automatically re-enqueue the workflow job and progress to the next step when all of the awaits
jobs have successfully finished. However, this means that after_perform
is not necessarily the same as after_finish
. In order to provide the opportunity for you to execute callback logic if and only if a job run has finished, we provide callback hooks for the finish
event.
For example, you could use this hook to immediately clean up the AcidicJob::Run
database record whenever the workflow job finishes successfully like so: