Add Oban Job to Workflow if Oban.insert is called from a Workflow context

Hi everyone!

I had an idea and wanted some thoughts on it from anyone interested. What if you could compose Workflows similar to Ecto’s Repo.transaction?

I have found myself wishing that while defining a Workflow I could call a function that calls Oban.insert and instead of it inserting a new Oban Job, it would instead add the Job to the Workflow.

I wanted to play around with it but didn’t know if there were any obvious reasons this wouldn’t work.

1 Like

Workflows work similarly to Ecto.Multi, where you’re adding jobs with explicit names and workflow options. If you were to do that in a Repo.transaction/1 style, you’d need an alternative to Oban.insert because each job requires a name, at minimum.

You could make this work with a few helper functions, but I don’t think the ergonomics are there.

1 Like