@sudowealth/schwab-api
Version:
TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety
43 lines (42 loc) • 1.21 kB
TypeScript
import { type Middleware } from './compose';
export interface RetryOptions {
/**
* Maximum number of retry attempts
* @default 3
*/
maxAttempts: number;
/**
* Base delay in milliseconds for exponential backoff
* @default 1000ms
*/
baseDelayMs: number;
/**
* Advanced retry options
*/
advanced?: {
/**
* Whether to respect Retry-After headers from the server
* @default true
*/
respectRetryAfter?: boolean;
/**
* Maximum delay in milliseconds
* This caps the exponential backoff to prevent excessive delays
* @default 30000ms (30 seconds)
*/
maxDelayMs?: number;
/**
* Whether to skip the rate limit middleware on retry attempts
* Setting this to true prevents double-queueing of retry attempts
* @default true
*/
skipRateLimitOnRetry?: boolean;
};
}
/**
* Creates middleware that automatically retries failed requests
*
* @param options Options for configuring retry behavior
* @returns Middleware function
*/
export declare function withRetry(options?: Partial<RetryOptions>): Middleware;