import { ILogger } from './types'; export type CircuitState = 'closed' | 'open' | 'half-open'; export interface CircuitBreakerOptions { failureThreshold: number; resetTimeoutMs: number; logger: ILogger; onStateChange?: (state: CircuitState, failures: number) => void; } /** * Circuit breaker to prevent cascading failures when the feature flag API is down. * * States: * - CLOSED: Requests pass through. Failures increment counter. * - OPEN: Requests are rejected immediately. After resetTimeoutMs, transitions to HALF-OPEN. * - HALF-OPEN: One probe request is allowed. Success → CLOSED, failure → OPEN. */ export declare class CircuitBreaker { private state; private failures; private lastFailureTime; private readonly options; constructor(options: CircuitBreakerOptions); getState(): CircuitState; getFailures(): number; /** * Execute a function through the circuit breaker. * If the circuit is open, throws immediately. * If the circuit is half-open, allows one probe request. */ execute(fn: () => Promise): Promise; /** * Manually reset the circuit to closed state. */ reset(): void; private onSuccess; private onFailure; private shouldAttemptReset; private transitionTo; } /** * Error thrown when the circuit breaker is open and rejecting requests. */ export declare class CircuitOpenError extends Error { readonly name = "CircuitOpenError"; constructor(message: string); }