//#region src/reconnect.d.ts /** * Pure-functional reconnect-backoff helper. Encapsulated in its own * module so the `GraphorinClient` stays free of timing * heuristics - and so tests can drive the policy with a deterministic * RNG. * * Algorithm: exponential backoff with full-jitter * (`delay = random(0, min(maxMs, baseMs * 2^(attempt-1)))`, with the * exponent clamped at 30, and `attempt` 1-indexed so attempt 1 sleeps * `random(0, baseMs)`). The * implementation matches the AWS Architecture Blog "exponential * backoff and jitter" reference but is otherwise an original * formulation. * * @packageDocumentation */ /** * Stable shape consumed by {@link computeBackoffMs}. * * @stable */ interface BackoffPolicy { /** Initial slot in milliseconds. Default `500`. */ readonly baseMs?: number; /** Cap on every individual sleep. Default `30_000`. */ readonly maxMs?: number; /** * Hard cap on the number of attempts. The client surfaces a * `TransportFailedError` once exceeded. Default `Infinity`. */ readonly maxAttempts?: number; /** * Optional injection seam used by tests; defaults to `Math.random`. */ readonly random?: () => number; } /** * Compute the number of milliseconds to sleep before the * `attempt`-th reconnect (1-indexed). Returns `null` when the policy * has been exhausted (`attempt > maxAttempts`). * * @stable */ declare function computeBackoffMs(attempt: number, policy?: BackoffPolicy): number | null; /** * Resolve when the requested number of milliseconds elapsed, or * reject (with a `DOMException`-style abort error) when the * supplied `AbortSignal` fires first. * * @stable */ declare function sleep(durationMs: number, signal?: AbortSignal): Promise; //#endregion export { BackoffPolicy, computeBackoffMs, sleep }; //# sourceMappingURL=reconnect.d.ts.map