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.

69 lines (68 loc) 1.78 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 PolynomialBackoffSettings = { /** * @default * ```ts * import { TimeSpan } from "@daiso-tech/core/time-span"; * * TimeSpan.fromSeconds(60) * ``` */ maxDelay?: ITimeSpan; /** * @default * ```ts * import { TimeSpan } from "@daiso-tech/core/time-span"; * * TimeSpan.fromSeconds(1) * ``` */ minDelay?: ITimeSpan; /** * @default 2 */ degree?: number; /** * 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 resolvePolynomialBackoffSettings(settings: PolynomialBackoffSettings): Required<PolynomialBackoffSettings>; /** * Polynomial backoff policy with jitter * * IMPORT_PATH: `"@daiso-tech/core/backoff-policies"` */ export declare function polynomialBackoff(settings?: DynamicBackoffPolicy<PolynomialBackoffSettings>): BackoffPolicy; /** * @internal */ export type SerializedPolynomialBackoffSettings = { maxDelay?: number; minDelay?: number; degree?: number; jitter?: number | null; _mathRandom?: number; }; /** * @internal */ export declare function serializePolynomialBackoffSettings(settings: PolynomialBackoffSettings): Required<SerializedPolynomialBackoffSettings>;