Setu-TS
    Preparing search index...

    Interface ICircuitBreaker

    Circuit breaker protecting calls to an unreliable dependency.

    const result = await breaker.execute(() => externalApi.fetchRates());
    

    0.1.0

    interface ICircuitBreaker {
        state: CircuitState;
        execute<T>(fn: ResilientCall<T>): Promise<T>;
    }
    Index

    The current circuit state.

    • Executes a call through the breaker.

      Type Parameters

      • T

        The call's result type

      Parameters

      • fn: ResilientCall<T>

        The protected call, handed the cancellation signal for this attempt

      Returns Promise<T>

      The call result

      Fails fast when the circuit is open; otherwise propagates the call's own error