UNPKG

@coinbase/onchaintestkit

Version:

End-to-end testing toolkit for blockchain applications, powered by Playwright

33 lines (32 loc) 1.17 kB
export interface BackoffConfig { baseDelay: number; maxDelay: number; multiplier: number; jitter: boolean; maxAttempts: number; } export interface RetryOptions { strategy: "exponential" | "linear" | "custom"; config: BackoffConfig; onRetry?: (attempt: number, delay: number) => void; } /** * Exponential backoff with optional jitter to prevent thundering herd */ export declare function exponentialBackoff(attempt: number, config?: Partial<BackoffConfig>): number; /** * Linear backoff with consistent increments */ export declare function linearBackoff(attempt: number, increment: number): number; /** * Custom backoff strategy with user-defined function */ export declare function customStrategy(attempt: number, strategy: (attempt: number, config: BackoffConfig) => number, config?: Partial<BackoffConfig>): number; /** * Create a delay function based on retry options */ export declare function createDelayFunction(options: RetryOptions): (attempt: number) => number; /** * Execute an operation with retry logic */ export declare function executeWithRetry<T>(operation: () => Promise<T>, options: RetryOptions): Promise<T>;