Packages
honeydew
1.4.2
1.5.0
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.0
1.2.8
1.2.7
1.2.6
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.6
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-rc7
1.0.0-rc6
1.0.0-rc5
1.0.0-rc4
1.0.0-rc3
1.0.0-rc2
1.0.0-rc1
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
Pluggable local/clusterable job queue focused on safety.
Current section
Files
Jump to
Current section
Files
lib/honeydew/worker_supervisor.ex
defmodule Honeydew.WorkerSupervisor do
@moduledoc false
use DynamicSupervisor, restart: :transient
alias Honeydew.Worker
def start_link([_queue, %{num: num}, _queue_pid] = opts) do
{:ok, supervisor} = DynamicSupervisor.start_link(__MODULE__, [num], [])
Enum.each(1..num, fn _ ->
start_worker([supervisor | opts])
end)
{:ok, supervisor}
end
@impl true
def init([num]) do
DynamicSupervisor.init(strategy: :one_for_one, max_restarts: num)
end
def start_worker([supervisor | _rest] = opts) do
spec = Worker.child_spec(opts)
{:ok, _} = DynamicSupervisor.start_child(supervisor, spec)
end
end