@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.8 kB
TypeScript
/**
* @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 ExponentialBackoffSettings = {
/**
* @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
*/
multiplier?: 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 resolveExponentialBackoffSettings(settings: ExponentialBackoffSettings): Required<ExponentialBackoffSettings>;
/**
* Exponential backoff policy with jitter
*
* IMPORT_PATH: `"@daiso-tech/core/backoff-policies"`
*/
export declare function exponentialBackoff(settings?: DynamicBackoffPolicy<ExponentialBackoffSettings>): BackoffPolicy;
/**
* @internal
*/
export type SerializedExponentialBackoffSettings = {
maxDelay?: number;
minDelay?: number;
multiplier?: number;
jitter?: number | null;
_mathRandom?: number;
};
/**
* @internal
*/
export declare function serializeExponentialBackoffSettings(settings: ExponentialBackoffSettings): Required<SerializedExponentialBackoffSettings>;