Logos DX
    Preparing search index...

    Type Alias CircuitBreakerOptions<T>

    Configuration options for circuit breaker behavior.

    type CircuitBreakerOptions<T extends Func> = {
        halfOpenMaxAttempts?: number;
        maxFailures?: number;
        onError?: (error: Error, args: Parameters<T>) => void;
        onHalfOpen?: (store: CircuitBreakerStore) => void;
        onReset?: () => void;
        onTripped?: (
            error: CircuitBreakerError,
            store: CircuitBreakerStore,
        ) => void;
        resetAfter?: number;
        shouldTripOnError?: (error: Error) => boolean;
    }

    Type Parameters

    • T extends Func

      The function type being protected

    Index

    Properties

    halfOpenMaxAttempts?: number

    Maximum number of test attempts allowed in half-open state

    1
    
    maxFailures?: number

    Maximum number of consecutive failures before tripping the circuit

    3
    
    onError?: (error: Error, args: Parameters<T>) => void

    Callback invoked when the protected function throws an error

    onHalfOpen?: (store: CircuitBreakerStore) => void

    Callback invoked when circuit breaker enters half-open state

    onReset?: () => void

    Callback invoked when circuit breaker resets (closes)

    onTripped?: (error: CircuitBreakerError, store: CircuitBreakerStore) => void

    Callback invoked when circuit breaker trips (opens)

    resetAfter?: number

    Time in milliseconds to wait before testing recovery

    1000
    
    shouldTripOnError?: (error: Error) => boolean

    Predicate function to determine if an error should trip the circuit

    all errors trip