1.0.3 • Published 8 years ago
promise-exponential-retry v1.0.3
Promise exponential retry
Just a simple utility to retry promises with exponential backoff.
Usage
Import NPM package:
npm i --save promise-exponential-retryImport RetryPromise in your source:
import { RetryPromise } from 'promise-exponential-retry';Wrap your promises using retryPromise():
return RetryPromise.retryPromise('getArrivalDepartures', () => {
// Return your actual promise here:
return new Promise<YourReturnType>((resolve, reject) => {
... // Your code
});
});The retryPromise() takes following arguments:
requestId: String that will be used in logging related to this promise.promiseLambda: A lambda that returns the promise you want to wrap.maxRetries: Maximum number of retries.initialDelay: How many millis to delay first retry.maxDelay: Maximum delay between retries.delayJitter: Jitter in millis to add to the delays.
Eg. If delayJitter = x, then delay could be random value betweendelay-xtodelay+x.