/********************************************************** * Copyright © 2023 Fict Ledger * All Rights Reserved. */ import { DEF_DELAY_MS } from "./delay.js"; export type TRetryFn = () => Promise; export interface IShouldRetryFnParams { lastError: Error | null; nRetryAttempt: number; maxRetryAttempts: number; } export type TShouldRetryFn = (params: IShouldRetryFnParams) => boolean; export type TOnErrFn = (err: unknown) => void | Promise; export declare const DEF_MAX_RECON_INT_MS = 60000; export declare const DEF_MAX_RECON_ATTEMPTS: number; export declare const DEF_SHOULD_RETRY_FN: TShouldRetryFn; export interface IRetryOptions { delayMS: number; maxRetryIntervalMS: number; maxRetryAttempts: number; shouldRetryFn: TShouldRetryFn; } export declare const DefaultRetryOptions: IRetryOptions; /** * Retries a promise-returning function until successfully resolved or * maxRetryAttempts are reached. * @template TResult * @param {TRetryFn} Fn - Function to retry * @param {IRetryOptions} options - Retry configuration * @param {TOnErrFn} onError - Gets called every time the function errors, useful for logging purposes * @returns {Promise} Promise that resolves if Fn succeeds within retry limits * @throws {Error} Last encountered error if retries are exhausted */ export declare function retryFn(Fn: TRetryFn, { delayMS, maxRetryIntervalMS, maxRetryAttempts, shouldRetryFn, }?: Partial, onError?: TOnErrFn): Promise; export { DEF_DELAY_MS }; //# sourceMappingURL=retriable-fn.d.ts.map