swarm v0.4.0 Swarm
This is the public Elixir API for :swarm
.
Summary
Functions
Join a process to a group
Leave a process group
Returns a list of pids which are members of the given group
Call all members of a group and return the results as a list
Publish a message to all members of a group
Registers the given name to the given pid, however names
registered this way will not be shifted when the cluster
topology changes, but this allows you to use :swarm
as
a distributed process registry, including registering names
with {:via, :swarm, name}
Similar to register_name/2, except this version takes module/function/args parameters, and starts the process, registers the pid with the given name, and handles cluster topology changes by restarting the process on it’s new node using the given MFA
This function sends a message to the process registered to the given name.
It is intended to be used by GenServer when using GenServer.cast/2
, but you
may use it to send any message to the desired process
Callback implementation for c:Application.start/2
Unregisters the given name from the registry
Get the pid of a registered name
Functions
Specs
members(term) :: [pid]
Returns a list of pids which are members of the given group.
Specs
multicall(term, term, pos_integer) :: [any]
Call all members of a group and return the results as a list.
Takes an optional timeout value. Any responses not received within this period are ignored. Default is 5s.
Specs
register_name(term, pid) :: :yes | :no
Registers the given name to the given pid, however names
registered this way will not be shifted when the cluster
topology changes, but this allows you to use :swarm
as
a distributed process registry, including registering names
with {:via, :swarm, name}
.
Specs
register_name(term, atom, atom, [term]) ::
{:ok, pid} |
{:error, term}
Similar to register_name/2, except this version takes module/function/args parameters, and starts the process, registers the pid with the given name, and handles cluster topology changes by restarting the process on it’s new node using the given MFA.
This version also returns an ok tuple with the pid if it registers successfully,
or an error tuple if registration fails. You cannot use this with processes which
are already started, it must be started by :swarm
.
Specs
send(term, term) :: :ok
This function sends a message to the process registered to the given name.
It is intended to be used by GenServer when using GenServer.cast/2
, but you
may use it to send any message to the desired process.
Specs
unregister_name(term) :: :ok
Unregisters the given name from the registry.