//#region src/ops/retrier.d.ts /** Options for configuring a {@link BackoffPolicy}. */ interface BackoffPolicyOptions { /** Initial delay in milliseconds; defaults to 1000. */ initial?: number; /** Maximum delay in milliseconds; defaults to 60000. */ maximum?: number; /** * Factor by which the delay is multiplied after each retry. The value must * be greater or equal to 1. If not, it defaults to 2. */ factor?: number; } declare const rand: { int(n: number): number; }; /** * BackoffPolicy implements an exponential backoff policy. The delay between * retries is randomly computed between 0 and the "exponential delay" as * recommended in [Exponential Backoff And Jitter]. The retry delay starts from * initial and grows exponentially by factor at every retry. The maximum retry * delay is capped by maximum. * * There is no parameter to limit the number of retries. This is intended as * such logic should be implemented upstream (e.g. in a Retrier). * * [Exponential Backoff And Jitter]: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/ */ declare class BackoffPolicy { /** Initial delay in milliseconds. */ readonly initial: number; /** Maximum delay in milliseconds. */ readonly maximum: number; /** Factor by which the delay is multiplied after each retry. */ readonly factor: number; private current; constructor(options?: BackoffPolicyOptions); /** Returns a random delay in [0, current] and grows the current delay. */ delay(): number; } /** Retrier defines a retry behavior. */ interface Retrier { /** * Returns the delay in milliseconds before the next retry, or undefined if * the error is not retriable. Implementations should assume that the given * error is never undefined. */ isRetriable(err: Error): number | undefined; } /** * Returns a Retrier that retries based on the isRetriable predicate and relies * on an internal backoff policy to decide how long to wait between retries. * * Important: the retrier has its own backoff policy which cannot be trivially * reset by design. Users who need to reset the backoff policy should rather * create a new retrier. */ declare function retryOn(options: BackoffPolicyOptions, isRetriable: (err: Error) => boolean): Retrier; //#endregion export { BackoffPolicy, BackoffPolicyOptions, Retrier, rand, retryOn }; //# sourceMappingURL=retrier.d.ts.map