circuit-breaker-as-promised

1.1.0 • Public • Published

circuit-breaker-as-promised

js-standard-style Circle CI Dependency Status

Hysterix-like circuit breaker for Javascript which wraps circuit-breaker-js and uses promises (via bluebird)

Installation

npm install --save circuit-breaker-as-promised

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 () {
  // Do stuff if you need to know when the breaker is open
})

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)
})

Package Sidebar

Install

npm i circuit-breaker-as-promised

Weekly Downloads

29

Version

1.1.0

License

MIT

Last publish

Collaborators

  • sharmarakesh
  • showvhick-winmore
  • arpit1024
  • rahulbharadwaj
  • jasif-wm
  • sidharth.n
  • renjith_ram_qburst
  • jyothis-qb
  • cdrohithmqb
  • dheerajds
  • arjunqb
  • lanetix-system
  • manu-kodiyan-winmore
  • dnm-winmore
  • mkdyanugk
  • vigneshk7
  • aswanth
  • sajith.qb
  • dhiluraj-qburst
  • apechimp