trade360-nodejs-sdk
Version:
LSports Trade360 SDK for Node.js
31 lines (30 loc) • 1.11 kB
TypeScript
import { ILogger } from '../logger';
/**
* Retry options for retrying an operation with
* exponential backoff based on the number of attempts
* and delay.
*/
interface RetryOptions {
maxAttempts: number;
delayMs: number;
backoffFactor?: number;
}
/**
* Retry an operation with exponential backoff based
* on the number of attempts and delay.
* @param operation the operation to retry
* @param options the retry options based on the number
* of attempts and delay in milliseconds with an optional.
* backoff factor for exponential backoff (default is 1).
* @param operationName the name of the operation for
* logging purposes.
* @param logger the logger to use for logging the
* operation.
* @returns the result of the operation if it succeeds
* after the number of attempts.
* @throws a RetryError if the operation fails after the
* number of attempts. The error contains the number of
* attempts made.
*/
export declare function withRetry<T>(operation: (...args: never[]) => Promise<T>, options: RetryOptions, operationName: string, logger: ILogger): Promise<T>;
export {};