UNPKG

@sailboat-computer/event-bus

Version:

Standardized event bus for sailboat computer v3 with resilience features and offline capabilities

49 lines 1.2 kB
/** * Retry utilities for the event bus */ /** * Retry options */ export interface RetryOptions { /** * Maximum number of retry attempts */ maxRetries: number; /** * Base delay in milliseconds */ baseDelay: number; /** * Maximum delay in milliseconds */ maxDelay: number; /** * Whether to use exponential backoff */ exponential: boolean; /** * Jitter factor (0-1) to add randomness to delays */ jitter: number; /** * Function to determine if an error is retryable */ isRetryable?: (error: Error) => boolean; /** * Function to call before each retry attempt */ onRetry?: (error: Error, attempt: number, delay: number) => void; } /** * Default retry options */ export declare const DEFAULT_RETRY_OPTIONS: RetryOptions; /** * Retry a function with exponential backoff * * @param fn - Function to retry * @param options - Retry options * @returns Promise that resolves with the function result or rejects with the last error */ export declare function retry<T>(fn: () => Promise<T>, options?: Partial<RetryOptions>): Promise<T>; //# sourceMappingURL=retry.d.ts.map