caf_components/gen_supervisor

Top-level supervisor of a hierarchy of components.

Configuration properties:

{interval: number, dieDelay: number, maxHangRetries: number}

where:

  • interval: time between health checks in milliseconds.
  • dieDelay: extra time in milliseconds before the process exits. A negative value disables process exit, i.e., enables a debugging mode.
  • maxHangRetries: number of times the health check can hang before exiting with an error. A hang check is the one that does not complete before the next check.
Source:

Extends

Methods

(static) create($, spec) → {Object}

Source:

Helper constructor method for a supervisor component.

Description of types in file types.js.

Parameters:
Name Type Description
$ ctxType

A context containing references to other components.

spec specType

Configuration data for this component.

Throws:

If inputs are invalid.

Type
Error
Returns:

A new generic component.

Type
Object

__ca_start__(notifyFopt, cbopt)

Source:

Starts the supervisor.

This supervisor can be started in two modes:

  1. Synchronous: A callback cb is provided. An initial checkup guarantees that the whole hierarchy is active before cb is called. Initialization errors are propated in the callback, and handled by the caller. After a successful initialization, the optional notifyF callback will be used for later checkups.

  2. Lazy: No cb callback. Internal components are lazily instantiated by the periodic checkups. If the optional notifyF is present, it is used to inform of errors or progress for each checkup.

Parameters:
Name Type Attributes Description
notifyF cbType <optional>

An optional callback to inform of the status of each health check.

cb cbType <optional>

An optional callback to switch to synchronous mode. It is invoked once after the first initialization attempt.

__ca_stop__()

Source:

Stops the periodic execution of health checks.

Shutting down a supervisor always stops checks.