UNPKG

@elastic.io/component-commons-library

Version:
27 lines (26 loc) 1.13 kB
import { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios'; export interface RetryOptions { retriesCount?: number; requestTimeout?: number; } export declare const API_RETRIES_COUNT: { readonly minValue: 0; readonly defaultValue: 3; readonly maxValue: 5; }; export declare const API_REQUEST_TIMEOUT: { readonly minValue: 500; readonly defaultValue: 15000; readonly maxValue: 120000; }; /** * if values are higher or lower the limit - they'll be overwritten. * returns valid values for RetryOptions */ export declare const getRetryOptions: () => RetryOptions; export declare const exponentialDelay: (currentRetries: number) => number; export declare const sleep: (ms: number) => Promise<unknown>; export declare const exponentialSleep: (currentRetries: number) => Promise<unknown>; export declare const getErrMsg: (errResponse: AxiosResponse) => string; export declare const axiosReqWithRetryOnServerError: (options: AxiosRequestConfig, axiosInstance?: AxiosInstance, logger?: any) => Promise<AxiosResponse<any, any>>; export declare const getFacelessRetriesCount: () => number;