DistributedSupervisor (distributed_supervisor v0.1.0)
View SourceDistributedSupervisor is exactly what its name says. It’s a DynamicSupervisor working
transparently in a distributed environment.
Example
iex|🌢|n1@am|1> DistributedSupervisor.start_link(name: DS)
{:ok, #PID<0.307.0>}
iex|🌢|n1@am|2> DistributedSupervisor.start_child(DS, {MyGenServer, name: MGS})
{:ok, #PID<0.311.0>, MGS}
iex|🌢|n1@am|3> DistributedSupervisor.children(DS)
%{MGS => #PID<0.311.0>}
Summary
Types
The id of the child process within the instance of the distributed supervisor.
Might be whatever. If not passed explicitly to the DistributedSupervisor.start_child/2,
the reference will be created automatically and returned as a third element
of the {:ok, pid, child_name} success tuple.
The name of the instance of this distributed supervisor.
Unlike GenServer.name/0, it must be an atom.
Functions
A syntactic sugar for GenServer.call/2 allowing to call a dynamically supervised
GenServer by registry name and key.
A syntactic sugar for GenServer.cast/2 allowing to call a dynamically supervised
GenServer by registry name and key.
Returns a specification to start this module under a supervisor.
Returns a map with registered names as keys and pids as values for the instance of the
registry with a name name.
A syntactic sugar for Kernel.send/2 allowing to send a message to
a dynamically supervised GenServer identified by registry name and key.
Dynamically adds a child specification to supervisor and starts that child.
Starts the DistributedSupervisor.
Returns a fully qualified name to use with a standard library functions,
accepting {:via, Registry, key} as a GenServer name.
Returns a t:pid() for the instance of the registry with a name name by key.
Types
@type id() :: term()
The id of the child process within the instance of the distributed supervisor.
Might be whatever. If not passed explicitly to the DistributedSupervisor.start_child/2,
the reference will be created automatically and returned as a third element
of the {:ok, pid, child_name} success tuple.
@type name() :: atom()
The name of the instance of this distributed supervisor.
Unlike GenServer.name/0, it must be an atom.
Functions
A syntactic sugar for GenServer.call/2 allowing to call a dynamically supervised
GenServer by registry name and key.
A syntactic sugar for GenServer.cast/2 allowing to call a dynamically supervised
GenServer by registry name and key.
Returns a specification to start this module under a supervisor.
See Supervisor.
Returns a map with registered names as keys and pids as values for the instance of the
registry with a name name.
A syntactic sugar for Kernel.send/2 allowing to send a message to
a dynamically supervised GenServer identified by registry name and key.
@spec start_child(name(), Supervisor.child_spec() | {module(), term()}) :: DynamicSupervisor.on_start_child()
Dynamically adds a child specification to supervisor and starts that child.
child_spec should be a valid child specification as detailed in the “Child specification”
section of the documentation for Supervisor expressed as a Supervisor.child_spec/0
or as a tuple {module, start_link_arg}.
The child process will be started as defined in the child specification. The core
difference from DynamicSupervisor is that the process must be named.
The name might be any term, passed through name: option in a call to this function.
If name option is not passed, it gets assigned randomly and returned in the third
element of the tuple from start_child/2.
Starts the DistributedSupervisor.
- required option
name :: DistributedSupervisor.name()the name of the supervisor to be used in lookups etc
Returns a fully qualified name to use with a standard library functions,
accepting {:via, Registry, key} as a GenServer name.
Returns a t:pid() for the instance of the registry with a name name by key.