UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

67 lines (66 loc) 2.31 kB
/** * @module CircuitBreaker */ import { type CircuitBreakerState, type CircuitBreakerTrigger, type ICircuitBreaker, type ICircuitBreakerAdapter, type CircuitBreakerEventMap } from "../../../../circuit-breaker/contracts/_module.js"; import { type IEventDispatcher } from "../../../../event-bus/contracts/_module.js"; import { type IExecutionContext } from "../../../../execution-context/contracts/_module.js"; import { type IKey, type INamespace } from "../../../../namespace/contracts/_module.js"; import { TimeSpan } from "../../../../time-span/implementations/_module.js"; import { type AsyncLazy, type ErrorPolicy, type WaitUntil } from "../../../../utilities/_module.js"; /** * @internal */ export type CircuitBreakerSettings = { enableAsyncTracking: boolean; eventDispatcher: IEventDispatcher<CircuitBreakerEventMap>; adapter: ICircuitBreakerAdapter; key: IKey; slowCallTime: TimeSpan; errorPolicy: ErrorPolicy; trigger: CircuitBreakerTrigger; serdeTransformerName: string; namespace: INamespace; waitUntil: WaitUntil; executionContext: IExecutionContext; }; /** * @internal */ export type ISerializedCircuitBreaker = { version: "1"; key: string; }; /** * @internal */ export declare class CircuitBreaker implements ICircuitBreaker { /** * @internal */ static _serialize(deserializedValue: CircuitBreaker): ISerializedCircuitBreaker; private readonly waitUntil; private readonly _key; private readonly errorPolicy; private readonly trigger; private readonly slowCallTime; private readonly adapter; private readonly eventDispatcher; private readonly serdeTransformerName; private readonly namespace; private readonly enableAsyncTracking; private readonly executionContext; constructor(settings: CircuitBreakerSettings); _getNamespace(): INamespace; _getSerdeTransformerName(): string; _getAdapter(): ICircuitBreakerAdapter; get key(): IKey; getState(): Promise<CircuitBreakerState>; private trackFailure; private trackSuccess; private trackErrorWrapper; private trackSlowCallWrapper; private guard; runOrFail<TValue = void>(asyncFn: AsyncLazy<TValue>): Promise<TValue>; reset(): Promise<void>; isolate(): Promise<void>; }