Module: caf_components/gen_dynamic_container

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

Container membership changes at run-time.

We use a supervisor strategy similar to Erlang/OTP one-for-one: components are assumed to be independent, and if one of them dies we just restart that component. Order of component shutdown or start is arbitrary.

The child's spec.env can contain a boolean attribute __ca_temporary__ that disables component restart. This is useful when we rely on external mechanisms to restart components, as is the case with CAs.

The following required properties specify recovery behavior for non-temporary components:

    { maxRetries: number, retryDelay: number}

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

Source:

Extends

Members

$ :Object.<string, Object>

A context to register children. We can pass an existing children context in $.$

Type:
  • Object.<string, Object>
Source:

__ca_isDynamicContainer__ :boolean

Run-time type information.

Type:
  • boolean
Source:

Methods

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

Helper constructor method for a dynamic 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.

Source:
Throws:

If inputs are invalid.

Type
Error
Returns:

A new generic component.

Type
Object

__ca_allChildren__() → {Array.<string>}

Returns an array with the names of all the children that are currently active.

Source:
Returns:

The names of all active children.

Type
Array.<string>

__ca_deleteChild__(dataopt, childName, cb)

Deletes and shutdowns a child component.

This is an idempotent operation.

Parameters:
Name Type Attributes Description
data Object <optional>

An optional hint on how to delete the child.

childName string

A name for the child.

cb cbType

A callback to return an error if a child still exists and delete failed.

Source:

__ca_getChildSpec__(name) → {specType}

Returns the spec for a created child.

Parameters:
Name Type Description
name string

The name of the child component.

Source:
Returns:

The spec of a running child.

Type
specType

__ca_instanceChild__(dataopt, childSpec, cb)

Adds a new child component if it was not already created.

We avoid race conditions by using a queue to serialize child creation.

There is no guarantee that the returned child used the provided description, it could have already been created with a different one. Use __ca_deleteChild__ first to force a description.

Parameters:
Name Type Attributes Description
data Object <optional>

An optional hint on how to add the child.

childSpec Object

A child description.

cb cbType

A callback to return an error or the new (or existing) child.

Source: