@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.
54 lines (53 loc) • 1.47 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 ConstantBackoffSettings = {
/**
* @default
* ```ts
* import { TimeSpan } from "@daiso-tech/core/time-span";
*
* TimeSpan.fromSeconds(1)
* ```
*/
delay?: 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 resolveConstantBackoffSettings(settings: ConstantBackoffSettings): Required<ConstantBackoffSettings>;
/**
* Constant backoff policy with jitter
*
* IMPORT_PATH: `"@daiso-tech/core/backoff-policies"`
*/
export declare function constantBackoff(settings?: DynamicBackoffPolicy<ConstantBackoffSettings>): BackoffPolicy;
/**
* @internal
*/
export type SerializedConstantBackoffSettings = {
delay?: number;
jitter?: number | null;
_mathRandom?: number;
};
/**
* @internal
*/
export declare function serializeConstantBackoffSettings(settings: ConstantBackoffSettings): Required<SerializedConstantBackoffSettings>;