Umbra v0.1.0 Umbra.Extension.NameSetter behaviour View Source
The extension Umbra.Extension.NameSetter
is used to manage the
GenServer name option.
It overrides the Umbra.GenServer.__start__/3
callback to set the process name (only if missing from options)
before starting the GenServer
.
This extension define a callback __get_process_name__/1
to retrieve/set name
depending of the state when start_link/2
or start/2
of your GenServer are called.
Example:
defmodule MyGenServer do
defstruct [:id, :other_states]
use Umbra.GenServer
use Umbra.Extension.NameSetter
@impl Umbra.Extension.NameSetter
def __get_process_name__(%__MODULE__{id: id}) do
{:ok, "MyGenServer::#{id}"}
end
# your code
end
Link to this section Summary
Callbacks
This callback is used to retrieve the process name depending of the parameter.
Link to this section Callbacks
Specs
This callback is used to retrieve the process name depending of the parameter.
It always returns {:ok, nil}
except if extensions are used.
The Umbra.Extension.Registry
extension did set this callback to
create the process name from the state thanks to a Registry
(also called a via_name
).
You have to take care of the declaration orders.