4.3.0 • Published 5 years ago

back-off v4.3.0

Weekly downloads
7,136
License
Unlicense
Repository
github
Last release
5 years ago

Back-Off

npm version Build Status Coverage Status

Circuit Breaker design pattern for JavaScript

circuit breaker

This module let's you use the Circuit Breaker pattern and call a function multiple times. In addition you can specify a delay to be applied between attempts as well as extending the delay as attempts are made.

Async/Await

const BackOff = require('back-off');
const backoff = new BackOff({
    times: 5, //number of times method should be called
    delay: 50, //delay in milliseconds between calls
    backoff: true // if the delay should be doubled between execution attempts
});
try {
  const result = await backoff.execute(asyncTask);
} catch (error) {
  //do something with the final error
}

Promise

const BackOff = require('back-off');
const backoff = new BackOff({
  times: 5, //number of times method should be called
  delay: 50, //delay in milliseconds between calls
  backoff: true // if the delay should be doubled between execution attempts
});

backoff.execute(() => {
  //do something here that may fail
})
.then(()=> {
  // do something else
})
.catch(() => {
  //attempts failed
});

The tests show the module in action.

4.3.0

5 years ago

4.2.1

5 years ago

4.2.0

5 years ago

4.1.0

5 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.0

6 years ago

2.0.0

8 years ago

1.0.0

10 years ago

0.9.0

10 years ago