Skip to main content
Dotset CLI API Documentation / index / CircuitBreaker

Class: CircuitBreaker

Defined in: src/mantle/errors/index.ts:751 Circuit breaker for handling cascading failures

Constructors

Constructor

new CircuitBreaker(name, options): CircuitBreaker;
Defined in: src/mantle/errors/index.ts:773

Parameters

name
string
options
CircuitBreakerOptions = {}

Returns

CircuitBreaker

Properties

name

readonly name: string;
Defined in: src/mantle/errors/index.ts:752

Methods

execute()

execute<T>(operation): Promise<T>;
Defined in: src/mantle/errors/index.ts:786 Execute a function through the circuit breaker

Type Parameters

T
T

Parameters

operation
() => Promise<T>

Returns

Promise<T>

getState()

getState(): CircuitState;
Defined in: src/mantle/errors/index.ts:849 Get current circuit breaker state

Returns

getStats()

getStats(): CircuitBreakerStats;
Defined in: src/mantle/errors/index.ts:860 Get circuit breaker statistics

Returns

isAllowing()

isAllowing(): boolean;
Defined in: src/mantle/errors/index.ts:878 Check if circuit breaker is allowing requests

Returns

boolean

reset()

reset(): void;
Defined in: src/mantle/errors/index.ts:838 Manually reset the circuit breaker

Returns

void

trip()

trip(): void;
Defined in: src/mantle/errors/index.ts:831 Manually trip the circuit breaker

Returns

void