kinetex - v1.0.0-rc.1
    Preparing search index...

    Class CircuitBreaker

    Per-key circuit breaker implementing the CLOSED → OPEN → HALF_OPEN state machine with sliding-window or consecutive-count failure detection.

    Thread-safe for async use. Rejects with CircuitOpenError when OPEN.

    const cb = new CircuitBreaker("api.example.com", { failureThreshold: 3 });
    const result = await cb.execute(() => fetch("https://api.example.com/data"));
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    Methods

    • Execute a function through the circuit breaker. Throws CircuitOpenError if the circuit is open. Records success/failure and transitions state accordingly.

      Type Parameters

      • T

      Parameters

      • fn: () => Promise<T>

      Returns Promise<T>

    • Manually reset the circuit to CLOSED — useful after a fix deployment.

      Returns void