/** * Retry strategy for Kubernetes operations */ import { Logger } from 'winston'; /** * Retry configuration options */ export interface RetryConfig { /** Maximum number of retry attempts */ maxAttempts: number; /** Initial delay in milliseconds before first retry */ initialDelayMs: number; /** Maximum delay in milliseconds between retries */ maxDelayMs: number; /** Exponential backoff factor (e.g., 2 for doubling) */ backoffMultiplier: number; /** Jitter factor (0-1) to randomize delays */ jitterFactor: number; /** Timeout for entire retry operation in milliseconds */ timeoutMs?: number; /** Custom function to determine if error is retryable */ isRetryable?: (error: any) => boolean; /** Callback for retry events */ onRetry?: (attempt: number, error: any, nextDelayMs: number) => void; } /** * Default retry configuration */ export declare const DEFAULT_RETRY_CONFIG: RetryConfig; /** * Preset configurations for common scenarios */ export declare const RETRY_PRESETS: { /** Fast retries for transient network issues */ readonly FAST: { readonly maxAttempts: 3; readonly initialDelayMs: 100; readonly maxDelayMs: 1000; readonly backoffMultiplier: 2; readonly jitterFactor: 0.1; readonly timeoutMs: 5000; }; /** Standard retries for most operations */ readonly STANDARD: RetryConfig; /** Aggressive retries for critical operations */ readonly AGGRESSIVE: { readonly maxAttempts: 5; readonly initialDelayMs: 500; readonly maxDelayMs: 60000; readonly backoffMultiplier: 2; readonly jitterFactor: 0.2; readonly timeoutMs: 300000; }; /** No retries */ readonly NONE: { readonly maxAttempts: 1; readonly initialDelayMs: 0; readonly maxDelayMs: 0; readonly backoffMultiplier: 1; readonly jitterFactor: 0; }; }; /** * Retry context for tracking state */ export interface RetryContext { attempt: number; totalDelay: number; startTime: number; errors: any[]; } /** * Result of a retry operation */ export interface RetryResult { success: boolean; value?: T; error?: any; attempts: number; totalDelayMs: number; totalTimeMs: number; } /** * Retry strategy implementation */ export declare class RetryStrategy { private readonly config; private readonly logger?; constructor(config?: Partial, logger?: Logger); /** * Execute an operation with retry logic */ execute(operation: () => Promise, operationName?: string): Promise>; /** * Wrap a function with retry logic */ wrap Promise>(fn: T, operationName?: string): T; /** * Determine if an error is retryable */ private shouldRetry; /** * Calculate delay for next retry attempt with exponential backoff and jitter */ private calculateDelay; /** * Delay execution for specified milliseconds */ private delay; } /** * Retry builder for fluent configuration */ export declare class RetryBuilder { private config; private logger?; withMaxAttempts(attempts: number): this; withInitialDelay(ms: number): this; withMaxDelay(ms: number): this; withBackoffMultiplier(multiplier: number): this; withJitterFactor(factor: number): this; withTimeout(ms: number): this; withRetryableCheck(fn: (error: any) => boolean): this; withRetryCallback(fn: (attempt: number, error: any, nextDelayMs: number) => void): this; withLogger(logger: Logger): this; withPreset(preset: keyof typeof RETRY_PRESETS): this; build(): RetryStrategy; } /** * Convenience function to create a retry strategy */ export declare function createRetryStrategy(config?: Partial, logger?: Logger): RetryStrategy; /** * Decorator for adding retry logic to methods */ export declare function Retryable(config?: Partial): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; //# sourceMappingURL=RetryStrategy.d.ts.map