/** * Minimal retry utility for token validation introspection. * * Retries a function with exponential backoff up to N attempts. * On failure after all attempts, returns a fallback result (fail-closed). * * @example * ```ts * const result = await WithRetry( * async (signal) => fetchData(signal), * { fallback: true }, * { maxAttempts: 3, timeoutMs: 5000 } * ); * ``` */ import type { Logger } from '@pawells/logger'; /** * Retry configuration */ export interface IRetryConfig { /** Maximum number of attempts (default: 3) */ maxAttempts?: number; /** Initial delay in milliseconds before first retry (default: 50) */ initialDelayMs?: number; /** Exponential backoff multiplier (default: 2) */ backoffMultiplier?: number; /** Maximum delay between retries in milliseconds (default: 1000) */ maxDelayMs?: number; /** Timeout for a single attempt in milliseconds (default: 5000) */ timeoutMs?: number; /** Optional logger for recording retry attempts and failures */ logger?: Pick; } /** * Execute a function with retry and timeout logic. * * Returns the result on success. After exhausting attempts, returns the fallback result * (fail-closed behavior). Uses exponential backoff with jitter to avoid thundering herd. * Logs errors at each retry attempt if a logger is provided in config. * * @param fn - The async function to retry * @param fallback - Result to return if all attempts fail * @param config - Retry configuration (optionally including a logger for error reporting) * @returns The result from fn on success, or fallback on failure after all retries * * @example * ```ts * const logger = new Logger('MyService'); * const result = await WithRetry( * async (signal) => fetchData(signal), * { fallback: true }, * { maxAttempts: 3, timeoutMs: 5000, logger } * ); * ``` */ export declare function WithRetry(fn: (signal: AbortSignal) => Promise, fallback: T, config?: IRetryConfig): Promise; //# sourceMappingURL=retry.d.ts.map