Locker.Registry
This module provides a global process registry using locker Erlang
library as the storage backend. It supports e.g., the GenServer‘s
{:via, module, term} API.
Example
You can spawn a regular GenServer process that will be registered
to locker using the GenServer API directly.
GenServer.start([], [name: {:via, Locker.Registry, "my_process"}])
Note that when using GenServer, you will need to refresh the registration
using Locker.extend_lease/3. To avoid this, you should use
Locker.Server instead of GenServer directly.
You can find out the process id of the named process using
Locker.Registry.whereis_name.
Locker.Registry.whereis_name("my_process")
#=> {:ok, pid}
You can uregister the named process by calling
Locker.Registry.unregister.
Locker.Registry.unregister("my_process")
Summary↑
| register_name(name, pid) | Registers the given |
| send(name, msg) | Sends a message to the given |
| unregister() | Unregisters the calling process |
| unregister_name(name) | Unregisters the given |
| whereis_name(name) | Finds the process identifier for the given |
Functions
Specs:
- register_name(any, pid) :: :yes | :no
Registers the given pid to a name globally.
Specs:
- send(any, any) :: :ok | {:badarg, {any, any}}
Sends a message to the given name.
Specs:
- unregister :: nil
Unregisters the calling process.
Specs:
- unregister_name(any) :: nil
Unregisters the given name.
Specs:
- whereis_name(any) :: pid | :undefined
Finds the process identifier for the given name.