Registry.start_link
You're seeing just the function
start_link
, go back to Registry module for more information.
Specs
start_link([start_option()]) :: {:ok, pid()} | {:error, term()}
Starts the registry as a supervisor process.
Manually it can be started as:
Registry.start_link(keys: :unique, name: MyApp.Registry)
In your supervisor tree, you would write:
Supervisor.start_link([
{Registry, keys: :unique, name: MyApp.Registry}
], strategy: :one_for_one)
For intensive workloads, the registry may also be partitioned (by specifying
the :partitions
option). If partitioning is required then a good default is to
set the number of partitions to the number of schedulers available:
Registry.start_link(
keys: :unique,
name: MyApp.Registry,
partitions: System.schedulers_online()
)
or:
Supervisor.start_link([
{Registry, keys: :unique, name: MyApp.Registry, partitions: System.schedulers_online()}
], strategy: :one_for_one)
Options
The registry requires the following keys:
:keys
- chooses if keys are:unique
or:duplicate
:name
- the name of the registry and its tables
The following keys are optional:
:partitions
- the number of partitions in the registry. Defaults to1
.:listeners
- a list of named processes which are notified of:register
and:unregister
events. The registered process must be monitored by the listener if the listener wants to be notified if the registered process crashes.:meta
- a keyword list of metadata to be attached to the registry.