retryable
Retry failed asynchronous calls or Promises.
Usage
var fs = retryable = open; // retryable wraps a function so that it retries forever by defaultopen = ; // retries can be limited; final err is passed to callbackopen"/tmp/foo" { /* ... */ }; // can unlimit limited retryable; unlimited passes no err to callbackopen"/tmp/foo" { /* ... */ }; // new function returns a Promise, so callback is optional; // customize retry backoff (default implementation shown)open = ;
API
Retryable
Wrapped retryable functions implement the Retryable interface.
Retryable#backoff(function)
Return a new retryable function with a custom backoff algorithm. The function
is bound to a RetryState instance. To maintaine state between backoff calls,
use something like this.data = "foo"
.
Retryable#retry(number)
Return a new retryable function which limits the number of retries. The
callback will ba passed the err
object unless the retries is Inifinity.
Passing a non-positive number will be treated like passing Infinity.