I’ve used the after_process/3
callback a number of times when implementing a Oban.Pro.Worker
and it tends to work great for handling any cleanup or updating something in the database based on the job status.
I have a situation today where I’m implementing a Oban.Pro.Workers.Workflow
with up to 3 dynamic child stages appended during execution and I realized I want to have a final callback that allows me to update a supporting record in the DB when the entire workflow completes. Reached for the after_process
callback and instinctively added that to my first workflow stage, but (logically in hindsight) it fires right when that first stage completes rather than the entire workflow itself.
My primary question here is if I am missing something on how to handle this via a callback when using workflows? Or is the answer to append that final step I hoped to handle in the callback as a child of the workflow as its own job or is it recommended to attach that callback to the final stage of my workflow?
I think what makes this a bit confusing is that we do have a workflow-centric callback in the form of after_cancelled/4
. So it seems like we should have some way to do the same for workflows that were not cancelled?
Appreciate any insight on this!
Update: I did just realize after_cancelled/4
is brand new as of last week. So maybe a similar approach for success cases is in the works