Hello!
I read this article - https://dockyard.com/blog/2019/04/02/three-simple-patterns-for-retrying-jobs-in-elixir (focus on section 3. Spawning Processes from GenServer for More Control with async_nolink)
Ok, this case described here as well - https://hexdocs.pm/elixir/Task.Supervisor.html#async_nolink/3-examples
So, if the task failed - then this callback is executed
def handle_info({:DOWN, ref, :process, _pid, _reason}, %{ref: ref} = state) do
# Log and possibly restart the task...
{:noreply, %{state | ref: nil}}
end
Looks great. In this callback i need to restart this task:
Task.Supervisor.async_nolink(MyApp.TaskSupervisor, module, :handle_start, [message])
BUT :
- my function :handle_start arity is 1.
- i don’t have argument message in callback
For easy restarts i can use Task.Supervisor.start_child, but it doesn’t replies result to GenServer back.