/** * @module CircuitBreaker */ import { type BackoffPolicy } from "../../../../backoff-policies/contracts/_module.js"; import { CIRCUIT_BREAKER_STATE, type ICircuitBreakerPolicy } from "../../../../circuit-breaker/contracts/_module.js"; /** * @internal */ export type BackoffPolicySettings = { currentDate: Date; backoffPolicy: BackoffPolicy; }; /** * @internal */ export type OpenedState = { type: typeof CIRCUIT_BREAKER_STATE.OPEN; attempt: number; /** * Unix timestamp in miliseconds */ startedAt: number; }; /** * @internal */ export type HalfOpenedState = { type: typeof CIRCUIT_BREAKER_STATE.HALF_OPEN; attempt: number; metrics: TMetrics; }; /** * @internal */ export type ClosedState = { type: typeof CIRCUIT_BREAKER_STATE.CLOSED; metrics: TMetrics; }; /** * @internal */ export type IsolatedState = { type: typeof CIRCUIT_BREAKER_STATE.ISOLATED; }; /** * @internal */ export type AllCircuitBreakerState = ClosedState | OpenedState | HalfOpenedState | IsolatedState; /** * @internal */ export declare class InternalCircuitBreakerPolicy { private readonly circuitBreakerPolicy; constructor(circuitBreakerPolicy: ICircuitBreakerPolicy); private isMetricsEqual; private isClosedStateEqual; private isOpenedStateEqual; private isHalfOpenedStateEqual; private isIsolatedStateEqual; isEqual(stateA: AllCircuitBreakerState, stateB: AllCircuitBreakerState): boolean; initialState(): ClosedState; whenClosed(currentState: ClosedState, currentDate: Date): ClosedState | OpenedState; whenOpened(currentState: OpenedState, settings: BackoffPolicySettings): OpenedState | HalfOpenedState; whenHalfOpened(currentState: HalfOpenedState, currentDate: Date): ClosedState | OpenedState | HalfOpenedState; trackSuccessWhenClosed(currentState: ClosedState, currentDate: Date): ClosedState; trackFailureWhenClosed(currentState: ClosedState, currentDate: Date): ClosedState; trackSuccessWhenHalfOpened(currentState: HalfOpenedState, currentDate: Date): HalfOpenedState; trackFailureWhenHalfOpened(currentState: HalfOpenedState, currentDate: Date): HalfOpenedState; }