GlobalChild (GlobalChild v0.2.1) View Source
Simple utility to provide a globally unique process in a cluster of Elixir nodes.
Usage
To start a globally unique child, wrap its child spec with a GlobalChild
child spec tuple:
children = [
# ...
{GlobalChild, child: {MyApp.Worker, name: {:global, :worker}}},
# ...
]
Options
:child
– Required. The child specification of the global process.:debug
– Optional, defaults tofalse
. Enables logger debug message whentrue
.:sleep
– Optional, defaults to0
. A duration in milliseconds to sleep for before attempting to start the global child. This is useful to let the cluster form and allow:global
to synchronize with other nodes. Without a delay, the process may start on several nodes, though eventually there will only be one left after:global
is synchronized. See:global.sync/0
if you need to enforce the synchronization.
Configuration
The default values for :debug
and :sleep
options can be set at the
configuration level. Those values are pulled at runtime.
config :global_child,
debug: true,
sleep: 1500
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.