brian.meeker

brian.meeker

Delaying Jobs In Oban Pro 1.5 Workflows

I’m using the new Oban Pro 1.5 workflow API. Currently, the workflow has three jobs. Job A runs first. Jobs B and C are dependent on A and can run concurrently.

Jobs A and B depend on a 3rd party API. We have recently learned that we need to add a couple of minute delay between jobs A and B. Job C can continue to run immediately after A completes. Is there a way to do this simply through Workflow configuration? Based on the the docs at Oban.Pro.Workflow — Oban Pro v1.5.0-rc.6, my current understanding is no.

If this is not something that workflows currently support, we have some options.

  1. Stop using workflows in this case. We don’t strictly need them here. We can manually enqueue jobs after each step.
  2. Add a no-op job into the workflow between A and B that just sleeps for a couple of minutes.

Most Liked

brian.meeker

brian.meeker

Thanks for the input on this. Of course, real world usage is more complicated than my simplified example, but this feedback put me down a good path.

Our workflows can get somewhat complicated and we want to define as much of them as possible up front to centralize the domain knowledge about how the business process operates. That means I want to avoid adding jobs dynamically as much as possible, which makes scheduled_at a tougher sell though.

We also have the issue that these jobs can be used in a couple of different workflows with slightly different contexts, so we don’t want to couple them together more than necessary.

However, we can use snoozing to get a similar result. Job B takes an argument telling it how long it snooze. When the job runs, we can check if it’s snoozed before (See Oban.Pro.Engines.Smart — Oban Pro v1.5.0-rc.6). If it hasn’t snoozed yet, then we snooze it for the passed in number of seconds.

The end result is that job A completes first. This unblocks job B. B runs and immediately snoozes for the configured amount of time.

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement