Back-Off
Circuit Breaker design pattern for JavaScript
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 = ;const 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; catch error //do something with the final error
Promise
const BackOff = ;const 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;
The tests show the module in action.