Promise ⇐ Promise

Kind: global class
Extends: Promise
Classdec: Extends bluebird so that our promises have some retry functionality.
See: bluebird documentation

new Promise()

Creates a new Promise.

promise.retry(fn, [opts]) ⇒ Promise

Adds a retry method to all Promise instances.

Kind: instance method of Promise
Overrides: retry
Returns: Promise - A Promise
Since: 3.0.0

Param Type Default Description
fn function The function to retry.
[opts] Opts Options to specify how retry works.
[opts.max] Integer 5 The amount of times to retry.
[opts.backoff] Integer 500 The amount to wait between retries. In miliseconds and cumulative.

Example

// Start the deamon
return serviceCmd(['start'], opts)

// And then retry 25 times until we've connected, increase delay between retries by 1 second
.retry(function() {
  log.verbose('Trying to connect to daemon.');
  return shell.sh([DOCKER_EXECUTABLE, 'info'], {mode: 'collect'});
}, {max: 25, backoff: 1000});

Promise.retry(fn, [opts]) ⇒ Promise

Adds a retry method to the bluebird Promise module.

Kind: static method of Promise
Returns: Promise - A Promise
Since: 3.0.0

Param Type Default Description
fn function The function to retry.
[opts] Opts Options to specify how retry works.
[opts.max] Integer 5 The amount of times to retry.
[opts.backoff] Integer 500 The amount to wait between retries. In miliseconds and cumulative.

Example

// Tries to get the container list with the default options
return Promise.retry(function() {
  return container.list(appName);
});

results matching ""

    No results matching ""