Packages
horde
0.5.0
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/registry_supervisor.ex
defmodule Horde.RegistrySupervisor do
@moduledoc false
use Supervisor
def init(options) do
root_name = get_root_name(options)
unless is_atom(root_name) do
raise ArgumentError,
"expected :root_name to be given and to be an atom, got: #{inspect(root_name)}"
end
children = [
{DeltaCrdt,
crdt: DeltaCrdt.AWLWWMap,
on_diffs: fn diffs -> send(root_name, {:crdt_update, diffs}) end,
name: crdt_name(root_name),
sync_interval: 100},
{Horde.RegistryImpl,
name: root_name,
meta: Keyword.get(options, :meta),
members: Keyword.get(options, :members),
init_module: Keyword.get(options, :init_module)}
]
Supervisor.init(children, strategy: :one_for_all)
end
defp get_root_name(options) do
root_name = Keyword.get(options, :root_name, nil)
if is_nil(root_name) do
raise "root_name must be specified in options. got: #{inspect(options)}"
end
root_name
end
def crdt_name(name), do: :"#{name}.Crdt"
end