intenta
v1.0.2
Published
Dead simple async retry with exponential backoff
Downloads
2
Readme
intenta
#intenta(fn, options)
Dead simple, zero deps, async retry with built in exponential backoff.
Super simple to use
const retry = require('intenta');
function updateDB(id, data, callback){
....
}
let retryUpdateDB = retry(updateDB);
retryUpdateDB(id, data, function(err, result){
....
});
Options
You can pass some options to intenta
limit
(Number) number of attempts to be madereport
(Bool) On success append the number of attempts made to callback argumentsbackoff
(Function) A custom backoff function with the signaturefn(attempt, error)
whereattempt
is an integer > 0. It should return the number of miliseconds to backoff. You can cancel retrying by returning -1. This allows you to stop retrying early i.e does not make any sense to retry after a 404 error.
report = true example
const retry = require('intenta');
function updateDB(id, data, callback){
....
}
let retryUpdateDB = retry(updateDB, {report: true});
retryUpdateDB(id, data, function(err, result, attemptsMade){
....
});