@push.rocks/webrequest
Version:
Modern, fetch-compatible web request library with intelligent HTTP caching, retry strategies, and fault tolerance.
33 lines (32 loc) • 938 B
TypeScript
/**
* Retry manager for handling request retries
*/
import type { IRetryOptions } from '../webrequest.types.js';
export declare class RetryManager {
private options;
constructor(options?: IRetryOptions);
/**
* Execute a request with retry logic
*/
execute<T>(executeFn: () => Promise<T>, shouldRetryFn?: (error: any, attempt: number) => boolean): Promise<T>;
/**
* Execute with multiple fallback URLs
*/
executeWithFallbacks(urls: string[], requestInit: RequestInit, fetchFn: (url: string, init: RequestInit) => Promise<Response>): Promise<Response>;
/**
* Check if we should retry based on response status
*/
private shouldRetryResponse;
/**
* Check if we should retry based on error
*/
private shouldRetryError;
/**
* Calculate delay for next retry
*/
private calculateDelay;
/**
* Delay execution
*/
private delay;
}