Commanded v0.15.0 Commanded.Registration behaviour View Source

Defines a behaviour for a process registry to be used by Commanded.

By default, Commanded will use a local process registry, defined in Commanded.Registration.LocalRegistry, that uses Elixir’s Registry module for local process registration. This limits Commanded to only run on a single node. However the Commanded.Registration behaviour can be implemented by a library to provide distributed process registration to support running on a cluster of nodes.

Link to this section Summary

Functions

Allow a registry provider to handle the standard GenServer callback functions

Use the Commanded.Registration module to import the registry and via tuple functions

Get the configured process registry

Callbacks

Return an optional supervisor spec for the registry

Sends a message to the given dest and returns :ok

Starts a uniquely named GenServer process for the given module and args

Return a :via tuple to route a message to a process by its registered name

Get the pid of a registered name

Link to this section Functions

Link to this macro __before_compile__(env) View Source (macro)

Allow a registry provider to handle the standard GenServer callback functions

Use the Commanded.Registration module to import the registry and via tuple functions.

Link to this function registry_provider() View Source
registry_provider() :: module()

Get the configured process registry.

Defaults to a local registry, restricted to running on a single node, if not configured.

Link to this function start_child(name, supervisor, args) View Source

Link to this section Callbacks

Link to this callback child_spec() View Source
child_spec() :: [:supervisor.child_spec()]

Return an optional supervisor spec for the registry

Link to this callback multi_send(dest, message) View Source
multi_send(dest :: atom(), message :: any()) :: :ok

Sends a message to the given dest and returns :ok.

Link to this callback start_child(name, supervisor, args) View Source
start_child(name :: term(), supervisor :: module(), args :: [any()]) ::
  {:ok, pid()} |
  {:error, reason :: term()}
start_child(name :: term(), supervisor :: module(), args :: [any()]) ::
  {:ok, pid()} |
  {:error, reason :: term()}
Link to this callback start_link(name, module, args) View Source
start_link(name :: term(), module :: module(), args :: any()) ::
  {:ok, pid()} |
  {:error, reason :: term()}

Starts a uniquely named GenServer process for the given module and args.

Registers the pid with the given name.

Link to this callback via_tuple(name) View Source
via_tuple(name :: term()) :: {:via, module(), name :: term()}

Return a :via tuple to route a message to a process by its registered name

Link to this callback whereis_name(name) View Source
whereis_name(name :: term()) :: pid() | :undefined

Get the pid of a registered name.

Returns :undefined if the name is unregistered.