Common functions for static and dynamic containers.
- Source:
Methods
(static) utils(that, maxRetries, retryDelay)
- Source:
Constructor of utils object.
Parameters:
| Name | Type | Description |
|---|---|---|
that |
Object | Target container object. |
maxRetries |
number | Number of retries before giving up. |
retryDelay |
number | Delay in msec before retrying. |
checkAndRestartChild(dataopt, doRetryopt) → {function}
- Source:
Returns a function that checks a child status, and restarts it if needed.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Object |
<optional> |
Optional meta-data for checks or to return info. If 'data.doNotRestart' is true, it does not attempt recovery, propagating an error in the callback. |
doRetry |
boolean |
<optional> |
True if it should retry a failed restart, otherwise no retry. |
Returns:
A function of type
function(specType, cbType) that will check and restart a child
component.
- Type
- function
checkChild(dataopt) → {function}
- Source:
Returns a function that checks a child status.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Object |
<optional> |
Optional meta-data for checks or to return info. |
Returns:
A function of type
function(string, cbType) that will check
a child component status. If the child is missing or shutdown it will
return an error using the callback.
- Type
- function
createChild(dataopt, doRetryopt) → {function}
- Source:
Returns a function that creates a new child. If necessary, the function shuts down first an existing one with the same name.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Object |
<optional> |
Optional meta-date for creation or to return info. |
doRetry |
boolean |
<optional> |
True if it should retry creation, otherwise no retry. |
Returns:
A function of type
function(specType, cbType) that will create
a child component from a description, and return it in the callback.
- Type
- function
ensureShutdown(f, dataopt, cb)
- Source:
Enforces a shutdown invariant for a function.
In particular, if the container is shutdown, all its children should also be shutdown.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
f |
function | A function of type
|
|
data |
Object |
<optional> |
Optional meta-data. |
cb |
cbType | A callback for |
many(method, all, dataopt, doRetryopt) → {function}
- Source:
Returns a function that serially executes a containerUtils method on
a collection of children.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
method |
string | A method name of this object (for example,
|
|
all |
Array.<(specType|string)> | Object.<string, specType> | An array of children or an object with a key with a child name and a value describing its spec. |
|
data |
Object |
<optional> |
Optional meta-data for methods, or to return info. |
doRetry |
boolean |
<optional> |
True if it should retry creation, otherwise no retry. |
Returns:
A function of type function(cbType) that
will asyncronously execute the method on the collection, and finally
invokes the callback with the results or an error.
- Type
- function
shutdownChild(dataopt, doRetryopt) → {function}
- Source:
Returns a function to shutdown a child.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Object |
<optional> |
Optional meta-data for shutdown or to return info. |
doRetry |
boolean |
<optional> |
True if it should retry shutdown, otherwise no retry. |
Returns:
A function of type
function(string, cbType) to shutdown a child component.
- Type
- function