Packages
commanded
1.4.7
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.3
1.4.2
1.4.1
1.4.0
1.4.0-rc.0
1.3.1
1.3.0
1.2.0
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc.1
1.0.0-rc.0
0.19.1
0.19.0
0.18.1
0.18.0
0.17.5
0.17.4
0.17.3
0.17.2
0.17.1
0.17.0
0.16.0
0.16.0-rc.1
0.16.0-rc.0
0.15.1
0.15.0
0.14.0
0.14.0-rc.0
0.13.0
0.12.0
0.11.0
0.10.0
0.9.0
0.8.5
0.8.4
0.8.3
0.8.1
0.8.0
0.7.1
0.6.2
0.6.1
0.6.0
0.4.0
0.3.1
0.3.0
0.2.1
0.2.0
0.1.0
Use Commanded to build your own Elixir applications following the CQRS/ES pattern.
Current section
Files
Jump to
Current section
Files
lib/commanded/registration/adapter.ex
defmodule Commanded.Registration.Adapter do
@moduledoc """
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.
"""
@type adapter_meta :: map()
@type application :: Commanded.Application.t()
@type config :: Keyword.t()
@type start_child_arg :: {module(), Keyword.t()} | module()
@doc """
Return an optional supervisor spec for the registry
"""
@callback child_spec(application, config) ::
{:ok, [:supervisor.child_spec() | {module, term} | module], adapter_meta}
@doc """
Use to start a supervisor.
"""
@callback supervisor_child_spec(adapter_meta, module :: atom, arg :: any()) ::
:supervisor.child_spec()
@doc """
Starts a uniquely named child process of a supervisor using the given module
and args.
Registers the pid with the given name.
"""
@callback start_child(
adapter_meta,
name :: term(),
supervisor :: module(),
child_spec :: start_child_arg
) ::
{:ok, pid} | {:error, term}
@doc """
Starts a uniquely named `GenServer` process for the given module and args.
Registers the pid with the given name.
"""
@callback start_link(
adapter_meta,
name :: term(),
module :: module(),
args :: any(),
start_options :: GenServer.options()
) :: {:ok, pid} | {:error, term}
@doc """
Get the pid of a registered name.
Returns `:undefined` if the name is unregistered.
"""
@callback whereis_name(adapter_meta, name :: term()) :: pid() | :undefined
@doc """
Return a `:via` tuple to route a message to a process by its registered name
"""
@callback via_tuple(adapter_meta, name :: term()) :: {:via, module(), name :: term()}
end