Socket
Book a DemoInstallSign in
Socket

@highoutput/circuit-breaker

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@highoutput/circuit-breaker

A fail-fast circuit breaker for async functions

latest
Source
npmnpm
Version
0.2.6
Version published
Maintainers
5
Created
Source

circuit-breaker

Executes and monitors the status of async functions. When the async function starts failing, @highoutput/circuit-breaker triggers an internal switch and prevents further executions. The internal switch is triggered when the failure rate (number of failures divided by the number of executions measured over a period) goes beyond the threshold.

Usage

import CircuitBreaker from '@highoutput/circuit-breaker';

const circuitBreaker = new CircuitBreaker({
  threshold: 0.35,
  timeout: 60000,
  rollingCountBuckets: 6,
  rollingCountInterval: 30000,
  resetTimeout: 300000,
  recoveryCountThreshold: 3,
  handler: async (params: { message: string }) => {
    return params.message;
  },
});

console.log(await circuitBreaker.exec({ message: 'Hello World' }));
// Hello World

Keywords

circuit-breaker

FAQs

Package last updated on 16 Mar 2022

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