@rhofkens/mcp-quotes-server-claude-code
Version:
Model Context Protocol (MCP) server for managing and serving quotes
49 lines • 1.57 kB
TypeScript
/**
* Retry Utility with Exponential Backoff
*
* Provides configurable retry logic with circuit breaker integration
*/
import type { CircuitBreaker } from './circuitBreaker.js';
/**
* Retry configuration options
*/
export interface RetryConfig {
maxAttempts?: number;
initialDelay?: number;
maxDelay?: number;
backoffFactor?: number;
jitter?: boolean;
retryableErrors?: Array<string | number>;
circuitBreaker?: CircuitBreaker;
onRetry?: (error: unknown, attempt: number) => void;
}
/**
* Retry statistics
*/
export interface RetryStats {
attempts: number;
totalDelay: number;
lastError?: unknown;
succeeded: boolean;
}
/**
* Execute a function with retry logic
*/
export declare function retry<T>(fn: () => Promise<T>, config?: RetryConfig): Promise<T>;
/**
* Retry decorator for class methods
*/
export declare function Retryable(config?: RetryConfig): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
/**
* Create a retry wrapper with preset configuration
*/
export declare function createRetryWrapper(config: RetryConfig): <T>(fn: () => Promise<T>) => Promise<T>;
/**
* Retry with linear backoff (for simpler cases)
*/
export declare function retryLinear<T>(fn: () => Promise<T>, maxAttempts?: number, delay?: number): Promise<T>;
/**
* Retry with immediate first attempt then exponential backoff
*/
export declare function retryImmediate<T>(fn: () => Promise<T>, config?: Omit<RetryConfig, 'initialDelay'>): Promise<T>;
//# sourceMappingURL=retry.d.ts.map