/** * @license * Copyright 2018 Palantir Technologies, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { FetchFunction } from "./fetchBridge"; /** * A backoff strategy must return either the number of milliseconds to wait before retrying * a request, or undefined to indicate we should stop backing-off (e.g. if the maximum number * of retries have been exceeded. */ export type BackoffStrategy = (attempt: number) => number | undefined; /** * Implements "exponential backoff with full jitter", suggesting a backoff duration chosen randomly from the interval * `[0, backoffSlotSize * 2^c)` for the c-th retry for a maximum of `maxNumRetries` retries. */ export declare function exponentialBackoff(maxNumRetries: number, backoffSlotSizeMs: number): BackoffStrategy; export declare class RetryingFetch { private delegate; private backoffStrategy; constructor(delegate: FetchFunction, backoffStrategy: BackoffStrategy); get fetch(): FetchFunction; private fetchInternal; private getRetryAfterHeaderValueInMilliseconds; private getRetryAfter; private doAttempt; }