Skip to content

revington/intenta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status Known Vulnerabilities

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 made
  • report (Bool) On success append the number of attempts made to callback arguments
  • backoff (Function) A custom backoff function with the signature fn(attempt, error) where attempt 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){
....
});

About

Dead simple async retry with exponential backoff

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published