circuit-breaker-as-promised
Hysterix-like circuit breaker for Javascript which wraps circuit-breaker-js and uses promises (via bluebird)
Installation
Usage
var request = require('http-as-promised')
var wrapWithBreaker = require('circuit-breaker-as-promised')
var BreakerOpen = wrapWithBreaker.BreakerOpen
var breakerRequest = wrapWithBreaker(request)
... Use as normal
breakerRequest('http://lol.com')
.catch(BreakerOpen, function () {
})
You often don't want, e.g., http client errors, to trip the breaker, but still
reject the returned promise as in the following example.
var breakerRequest = wrapWithBreaker(request, function (res) {
return res.catch(request.error.client)
})