UNPKG

@seriouslag/httpclient

Version:
30 lines (29 loc) 1.26 kB
import { HttpRequestStrategy } from '../HttpRequestStrategies/HttpRequestStrategy'; import { Request, HttpResponse } from '../Adaptors'; export interface ExponentialBackoffOptions { /** Determines if the first request will be delayed */ delayFirstRequest?: boolean; /** The maximum number of retries to attempt, default is 5, set to 0 for indefinite retries */ maxRetryCount?: number; /** The base delay in milliseconds, will be used to calculate backoff */ baseDelay?: number; /** The maximum delay to use; set to -1 or undefined for no cap */ maxDelay?: number; /** The factor that will be used to grow the delay */ factor?: number; } /** Retries HTTP requests with a specified backoff strategy until the max retry count. */ export declare class ExponentialBackoffRequestStrategy implements HttpRequestStrategy { private options; /** TOO MANY REQUESTS STATUS CODE */ private TOO_MANY_REQUESTS_STATUS; private delayFirstRequest; private maxRetryCount; private baseDelay; private factor; private maxDelay; constructor(options?: ExponentialBackoffOptions); request<T = unknown>(request: Request<T>): Promise<HttpResponse<T>>; private getIsAtRetryMax; private getShouldDelay; }