3 ms·
Let's go for that one. Processing a million jobs in parallel is not hard my_list_of_job |> distribute_tasks() |> Enum.map(fn x -> Task.Supervisor.async(
by di4na 10y ago
Let's go for that one. Processing a million jobs in parallel is not hard
my_list_of_job
|> distribute_tasks()
|> Enum.map(fn x -> Task.Supervisor.async(x, my_list_of_job) end)
|> Enum.map(fn x -> Task.await(x, your_timeout) end)
That is will distribute your worload on all the nodes you have that implement a runner for that. Of course you may want to make things a bit different, and i did not covered your load balancing that i hidden in distribute task, nor any error handling, but that would not be far harder imho. Until you enter the partition and idempotent part, but even that would not be that hard.
There is a long running project to work on that to produce a nice job queue lib on Elixir Slack but noone on the interested group have time for now.
To schedule a job to run in a week you have a couple way. An easy first approach is to use Process.send_after/3 to send yourself a message after a week and handle that message in a week. Of course if you want persistence, etc, you will have to do it a bit differently, but not so much....
edit : now use the fn form instead of the shorthand & for ease of comprehension for non seasoned Elixir devs