caf_components/gen_container

Generic container component that encapsulates the life-cycle of other components.

A container is static, using a description list to create child components, allocating a new context to register them, and propagating actions as needed. Unknown children are shutdown without triggering a recovery strategy.

We use a supervisor strategy similar to Erlang/OTP one-for-all: If a child is missing or shutdown, we will shutdown all the remaining children first, and then restart them all. Recovery actions order is based on description order, to ensure that dependent services will also recover.

The following required properties specify recovery behavior:

    { maxRetries: number, retryDelay: number}

where maxRetries is the number of attempts before giving up, and retryDelay is the delay in msec between attempts.

We want to avoid split brain situations: two instances of the same component assuming that they are unique, and, for example, interacting with the external world.

For this reason, we cannot restart a child until a previous shutdown has been successful. Shutdown is always idempotent, and we retry multiple times. Eventually we give up and trigger a process shutdown, relying on an external recovery mechanism to restart the process.

Static containers are not adequate for managing CAs. CAs are mostly independent from each other, and created dynamically. See gen_dynamic_container for an alternative.

Source:

Extends

Members

$ :ctxType

Source:

A context to register children.

Provide an existing children context in $.$, otherwise a new one is created.

Type:

__ca_isContainer__ :boolean

Source:

Run-time type information.

Type:
  • boolean

Methods

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

Source:

Helper constructor method for a container 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_getChildrenSpec__() → {Array.<specType>}

Source:

Gets a description of the expected children.

Returns:

A description of the expected children.

Type
Array.<specType>