I run supervised tasks via async_nolink and at the end await for multiple results with Task.yield_many
- example code:
request =
1..10
|> Enum.map fn x ->
result = Task.Supervisor.async_nolink(Final.TaskSupervisor, fn ->
res = case x do
2 -> x + "abc"
_ -> x + x
end
end)
end
results = Task.yield_many(request, 5000)
Now when task called by "2" crashes, how can I identify the number? Or in real-world, that would be event that started the task(domain name in my case).
I wrote long reduce code that saves tasks in one list, tuples of task.ref
and identifier(domain name) in another. Then I am combining this tasks with another group of tasks and after yield_many
cross comparing again... Seems way too messy for beautiful language like elixir :)
Am I missing some simpler alternative ?