Supervisor.child_spec
You're seeing just the function
child_spec
, go back to Supervisor module for more information.
Specs
child_spec(child_spec() | {module(), arg :: term()} | module(), keyword()) :: child_spec()
Builds and overrides a child specification.
Similar to start_link/2
and init/2
, it expects a
module
, {module, arg}
or a map as the child specification.
If a module is given, the specification is retrieved by calling
module.child_spec(arg)
.
After the child specification is retrieved, the fields on overrides
are directly applied on the child spec. If overrides
has keys that
do not map to any child specification field, an error is raised.
See the "Child specification" section in the module documentation for all of the available keys for overriding.
Examples
This function is often used to set an :id
option when
the same module needs to be started multiple times in the
supervision tree:
Supervisor.child_spec({Agent, fn -> :ok end}, id: {Agent, 1})
#=> %{id: {Agent, 1},
#=> start: {Agent, :start_link, [fn -> :ok end]}}