method CircuitBreaker.prototype.execute
CircuitBreaker.prototype.execute<T>(fn: () => Promise<T>): Promise<T>

Executes a function with circuit breaker protection

Type Parameters

Parameters

fn: () => Promise<T>
  • Async function to execute

Return Type

Promise<T>

Result of the function

Throws

CircuitBreakerOpenError if circuit is open

Error from the executed function if it fails

Usage

import { CircuitBreaker } from ".";