Packages
honeydew
0.0.1
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/honey_supervisor.ex
defmodule Honeydew.HoneySupervisor do
alias Honeydew.Honey
def start_link(honey_module, honey_init_args, num_workers, init_retry_secs) do
import Supervisor.Spec
children = [
worker(Honey, [], restart: :transient)
]
opts = [strategy: :simple_one_for_one, name: Honeydew.honey_supervisor(honey_module)]
{:ok, honey_supervisor} = Supervisor.start_link(children, opts)
# let the honey supervisor finish starting, then try to start children asynchronously.
Enum.each(1..num_workers, fn(_) ->
:timer.apply_after(0, __MODULE__, :start_child, [honey_module, honey_init_args, init_retry_secs])
end)
{:ok, honey_supervisor}
end
@doc "Starts a new worker for the given `honey_module` with the arguments `honey_init_args` and respawn delay `init_retry_secs`"
def start_child(honey_module, honey_init_args, init_retry_secs) do
honey_supervisor = Honeydew.honey_supervisor(honey_module)
Supervisor.start_child(honey_supervisor, [honey_module, honey_init_args, init_retry_secs])
end
end