View Source ebus_supervisor_spec (ebus v0.3.0)

Utility module to create supervisor and worker specs.

Link to this section Summary

Functions

Receives a list of children (workers or supervisors) to supervise and a set of options. Returns a tuple containing the supervisor specification.

Defines the given Module as a supervisor which will be started with the given arguments.

Defines the given Module as a worker which will be started with the given arguments.

Link to this section Functions

Link to this function

supervise(Children, SupFlags)

View Source
-spec supervise([supervisor:child_spec()], supervisor:sup_flags()) -> {ok, tuple()}.

Receives a list of children (workers or supervisors) to supervise and a set of options. Returns a tuple containing the supervisor specification.

Example:

  ebus_supervisor_spec:supervise(Children, #{strategy => one_for_one}).
Link to this function

supervisor(Module, Args)

View Source

Equivalent to supervisor(Module, Args, []).

Link to this function

supervisor(Module, Args, Spec)

View Source
-spec supervisor(module(), [term()], map()) -> supervisor:child_spec().

Defines the given Module as a supervisor which will be started with the given arguments.

Example:

  ebus_supervisor_spec:supervisor(my_sup, [], #{restart => permanent}).

By default, the function start_link is invoked on the given module. Overall, the default values for the options are:

  #{
    id       => Module,
    start    => {Module, start_link, Args},
    restart  => permanent,
    shutdown => infinity,
    modules  => [module]
  }

Equivalent to worker(Module, Args, []).

Link to this function

worker(Module, Args, Spec)

View Source
-spec worker(module(), [term()], map()) -> supervisor:child_spec().

Defines the given Module as a worker which will be started with the given arguments.

Example:

  ebus_supervisor_spec:worker(my_module, [], #{restart => permanent}).

By default, the function start_link is invoked on the given module. Overall, the default values for the options are:

  #{
    id       => Module,
    start    => {Module, start_link, Args},
    restart  => permanent,
    shutdown => 5000,
    modules  => [module]
  }