/** * @module Resilience */ import { type MiddlewareFn } from "../../../middleware/contracts/_module.js"; import { type ITimeSpan } from "../../../time-span/contracts/_module.js"; import { TimeSpan } from "../../../time-span/implementations/_module.js"; import { type Invocable } from "../../../utilities/_module.js"; /** * IMPORT_PATH: `"@daiso-tech/core/resilience"` * @group Middlewares */ export type OnTimeoutData = Array> = { waitTime: TimeSpan; args: TParameters; }; /** * IMPORT_PATH: `"@daiso-tech/core/resilience"` * @group Middlewares */ export type OnTimeout = Array> = Invocable<[data: OnTimeoutData]>; /** * IMPORT_PATH: `"@daiso-tech/core/resilience"` * @group Middlewares */ export type TimeoutCallbacks = Array> = { /** * Callback {@link Invocable | `Invocable`} that will be called before the timeout occurs. */ onTimeout?: OnTimeout; }; /** * Configuration for the `timeout` resilience middleware. * Rejects if the middleware result does not complete within the specified time; it does not cancel or abort next(). * * IMPORT_PATH: `"@daiso-tech/core/resilience"` * @group Middlewares */ export type TimeoutSettings = Array> = TimeoutCallbacks & { /** * The maximum time to wait before automatically aborting the executing function. * * @default * ```ts * import { TimeSpan } from "@daiso-tech/core/time-span"; * * TimeSpan.fromSeconds(2) * ``` */ waitTime?: ITimeSpan; }; /** * The `timeout` middleware automatically cancels functions after a specified time period, throwing an error when aborted. * * IMPORT_PATH: `"@daiso-tech/core/resilience"` * @group Middlewares * @throws {TimeoutResilienceError} */ export declare function timeout, TReturn>(settings?: NoInfer>): MiddlewareFn>;