node-breaker
A configurable implementation of the reset circuit breaker pattern
Installation
npm i node-breaker -S
Usage
const breaker = // breaker(functionToWra, [options])const fn = // call wrapped function as normal // wrapped functions always return a promise.// resolves with whatever was returned from the wrapped function// or rejects with any errors encountered // returned data // error encountered // if function fails more than maxFailCount, circuit// breaks and will instantly fail calls // 'Circuit opened' // after resetTimeout seconds, circuit half closes.// if no errors encountered, circuit closes again// otherwise circuit opens and resetTimeout seconds must pass again // success, circuit closed // failure, circuit opened again