Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

circuit-breaker-as-promised

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

circuit-breaker-as-promised

Hysterix-like circuit breaker with promise api

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
34
70%
Maintainers
2
Weekly downloads
 
Created
Source

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

Keywords

promise

FAQs

Package last updated on 21 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts