Commanded.Registration.Adapter behaviour (Commanded v1.3.1) 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

Callbacks

Return an optional supervisor spec for the registry

Starts a uniquely named child process of a supervisor using the given module and args.

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 Types

Specs

adapter_meta() :: map()

Specs

application() :: Commanded.Application.t()

Specs

config() :: Keyword.t()

Specs

start_child_arg() :: {module(), Keyword.t()} | module()

Link to this section Callbacks

Link to this callback

child_spec(application, config)

View Source

Specs

child_spec(application(), config()) ::
  {:ok, [:supervisor.child_spec() | {module(), term()} | module()],
   adapter_meta()}

Return an optional supervisor spec for the registry

Link to this callback

start_child(adapter_meta, name, supervisor, child_spec)

View Source

Specs

start_child(
  adapter_meta(),
  name :: term(),
  supervisor :: module(),
  child_spec :: start_child_arg()
) :: {:ok, pid()} | {:error, term()}

Starts a uniquely named child process of a supervisor using the given module and args.

Registers the pid with the given name.

Link to this callback

start_link(adapter_meta, name, module, args, start_options)

View Source

Specs

start_link(
  adapter_meta(),
  name :: term(),
  module :: module(),
  args :: any(),
  start_options :: GenServer.options()
) :: {:ok, pid()} | {:error, term()}

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

Registers the pid with the given name.

Link to this callback

supervisor_child_spec(adapter_meta, module, arg)

View Source

Specs

supervisor_child_spec(adapter_meta(), module :: atom(), arg :: any()) ::
  :supervisor.child_spec()

Use to start a supervisor.

Link to this callback

via_tuple(adapter_meta, name)

View Source

Specs

via_tuple(adapter_meta(), 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(adapter_meta, name)

View Source

Specs

whereis_name(adapter_meta(), name :: term()) :: pid() | :undefined

Get the pid of a registered name.

Returns :undefined if the name is unregistered.