ryanwinchester

ryanwinchester

Oban Sub-Workflow inherits parent initial context and ignores any additional context

(Oban Pro 1.6.0-rc.4)

When I create a sub-workflow, it gets the parent workflow’s put_context
while losing the parent workflows add_cascade additions to context
as well as the sub-workflow’s own put_context

Example of what I am experiencing (simplified):

def foo_workflow do
  Workflow.new()
  |> Workflow.put_context(%{foo: 1})
  |> Workflow.add_cascade(:bar, &get_bar/1)
  |> Workflow.add_graft(:baz, &baz_workflow/1)
end

def get_bar(%{}), do: 2

def baz_workflow(%{}) do
  Workflow.new()
  |> Workflow.put_context(%{banana: "yum"})
  |> Workflow.add_cascade(:help, &help/1)
  |> Workflow.apply_graft()
  |> Oban.insert_all()

  :ok
end

def help(%{banana: banana}) do
  # this will not match because it has:
  #  
  #     %{foo: 1}
  #
  # but I am expecting to be able to match
  # on `:banana` key.
  #
  # Sometimes `baz_workflow` is used on its own,
  # and sometimes as a sub-workflow in `foo_workflow`.
end

Marked As Solved

sorentwo

sorentwo

Oban Core Team

It wasn’t supposed to be. Just a bug in the query. It’s fixed for the next RC, slated in the next couple of days.

Also Liked

sorentwo

sorentwo

Oban Core Team

Thanks for the report! You’ve hit on some things that should be explained, warned about, or possibly fixed in workflows.

The context is pulled from the current workflow, then the parent workflow if nothing was found; they aren’t merged. They certainly could be though. The top level cascade (:bar) could probably be propagated down to the sub-workflow as well.

Looking into some fixes and improvements now.

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement