Packages
horde
0.4.0-rc.1
0.10.0
0.9.1
0.9.0
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.8.0-rc.1
0.7.1
0.7.0
0.6.1
0.6.0
0.6.0-rc.1
0.5.0
0.5.0-rc.12
0.5.0-rc.11
0.5.0-rc.10
0.5.0-rc.9
0.5.0-rc.8
0.5.0-rc.7
0.5.0-rc.6
0.5.0-rc.5
0.5.0-rc.4
0.5.0-rc.3
0.5.0-rc.2
0.5.0-rc.1
0.4.0-rc.2
0.4.0-rc.1
0.3.0
0.3.0-rc1
0.2.3
0.2.2
0.2.1
0.2.0
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Distributed supervisor & process registry built with DELTA-CRDTs
Current section
Files
Jump to
Current section
Files
lib/horde/process_supervisor.ex
defmodule Horde.ProcessSupervisor do
@moduledoc false
use Supervisor
def child_spec({child_spec, graceful_shutdown_manager, node_id, options}) do
%{
id: child_spec.id,
start: {__MODULE__, :start_link, [child_spec, graceful_shutdown_manager, node_id, options]},
type: :supervisor
}
end
def start_link(child_spec, graceful_shutdown_manager, node_id, options) do
Supervisor.start_link(
__MODULE__,
{child_spec, graceful_shutdown_manager, options},
name: name(node_id, child_spec.id)
)
end
def name(node_id, child_id) do
:"#{__MODULE__}.#{Base.encode16(node_id)}.#{term_to_string_identifier(child_id)}"
end
def init({child_spec, graceful_shutdown_manager, options}) do
options = Keyword.put(options, :strategy, :one_for_one)
children = [
{Horde.ProcessCanary, {child_spec, graceful_shutdown_manager}}
]
Supervisor.init(children, options)
end
defp term_to_string_identifier(term), do: term |> :erlang.term_to_binary() |> Base.encode16()
end