/** * @module CircuitBreaker */ import { type ICircuitBreaker } from "../../circuit-breaker/contracts/circuit-breaker.contract.js"; import { type ITimeSpan } from "../../time-span/contracts/time-span.contract.js"; import { type ErrorPolicySettings } from "../../utilities/_module.js"; /** * IMPORT_PATH: `"@daiso-tech/core/circuit-breaker/contracts"` * @group Contracts */ export declare const CIRCUIT_BREAKER_TRIGGER: { readonly ONLY_ERROR: "ONLY_ERROR"; readonly ONLY_SLOW_CALL: "ONLY_SLOW_CALL"; readonly BOTH: "BOTH"; }; /** * IMPORT_PATH: `"@daiso-tech/core/circuit-breaker/contracts"` * @group Contracts */ export type CircuitBreakerTrigger = (typeof CIRCUIT_BREAKER_TRIGGER)[keyof typeof CIRCUIT_BREAKER_TRIGGER]; /** * Configuration settings for creating a circuit breaker instance through the factory. * * IMPORT_PATH: `"@daiso-tech/core/circuit-breaker/contracts"` * @group Contracts */ export type CircuitBreakerFactoryCreateSettings = ErrorPolicySettings & { /** * Specifies what conditions are tracked as failures and trigger state transitions. * - `ONLY_ERROR`: Only failed invocations count as failures * - `ONLY_SLOW_CALL`: Only slow invocations count as failures * - `BOTH`: Both errors and slow calls count as failures */ trigger?: CircuitBreakerTrigger; /** * Threshold for determining if an invocation is considered "slow". * Any invocation exceeding this duration will be marked as a slow call if tracking is enabled via the `trigger` setting. * Only relevant when `trigger` is `ONLY_SLOW_CALL` or `BOTH`. */ slowCallTime?: ITimeSpan; }; /** * IMPORT_PATH: `"@daiso-tech/core/circuit-breaker/contracts"` * @group Contracts */ export type ICircuitBreakerFactory = { /** * The `create` method is used to create an instance of {@link ICircuitBreaker | `ICircuitBreaker`}. */ create(key: string, settings?: CircuitBreakerFactoryCreateSettings): ICircuitBreaker; };