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.

64 lines (63 loc) 1.66 kB
/** * @module BackoffPolicy */ import { type BackoffPolicy, type DynamicBackoffPolicy } from "../../backoff-policies/_shared.js"; import { type ITimeSpan } from "../../time-span/contracts/_module.js"; /** * * IMPORT_PATH: `"@daiso-tech/core/backoff-policies"` */ export type LinearBackoffSettings = { /** * @default * ```ts * import { TimeSpan } from "@daiso-tech/core/time-span"; * * TimeSpan.fromSeconds(6) * ``` */ maxDelay?: ITimeSpan; /** * @default * ```ts * import { TimeSpan } from "@daiso-tech/core/time-span"; * * TimeSpan.fromSeconds(1) * ``` */ minDelay?: ITimeSpan; /** * You can pass jitter value to ensure the backoff will not execute at the same time. * If you pas null you can disable the jitrter. * @default 0.5 */ jitter?: number | null; /** * @internal * Should only be used for testing */ _mathRandom?: () => number; }; /** * @internal */ export declare function resolveLinearBackoffSettings(settings: LinearBackoffSettings): Required<LinearBackoffSettings>; /** * Linear backoff policy with jitter * * IMPORT_PATH: `"@daiso-tech/core/backoff-policies"` */ export declare function linearBackoff(settings?: DynamicBackoffPolicy<LinearBackoffSettings>): BackoffPolicy; /** * @internal */ export type SerializedLinearBackoffSettings = { maxDelay?: number; minDelay?: number; jitter?: number | null; _mathRandom?: number; }; /** * @internal */ export declare function serializeLinearBackoffSettings(settings: LinearBackoffSettings): Required<SerializedLinearBackoffSettings>;