UNPKG

firewalla-mcp-server

Version:

Model Context Protocol (MCP) server for Firewalla MSP API - Provides real-time network monitoring, security analysis, and firewall management through 28 specialized tools compatible with any MCP client

103 lines 3.18 kB
/** * Retry Management Utilities for Firewalla MCP Server * Provides exponential backoff retry logic for timeout-prone operations */ /** * Enhanced error with retry context information */ export interface RetryFailureError extends Error { retryContext: { originalError: unknown; toolName: string; attempts: number; totalDurationMs: number; attemptDetails: Array<{ attempt: number; durationMs: number; error?: string; delayMs?: number; }>; }; userGuidance: string[]; } /** * Retry configuration options */ export interface RetryConfig { /** Maximum number of retry attempts */ maxAttempts?: number; /** Initial delay in milliseconds */ initialDelayMs?: number; /** Maximum delay in milliseconds */ maxDelayMs?: number; /** Exponential backoff multiplier */ backoffMultiplier?: number; /** Whether to add jitter to prevent thundering herd */ addJitter?: boolean; /** Function to determine if an error should trigger a retry */ shouldRetry?: (error: unknown, attempt: number) => boolean; /** Tool name for logging context */ toolName?: string; } /** * Result of a retry operation */ export interface RetryResult<T> { /** The successful result */ result?: T; /** The final error if all retries failed */ error?: unknown; /** Number of attempts made */ attempts: number; /** Total time spent retrying */ totalDurationMs: number; /** Whether the operation ultimately succeeded */ success: boolean; /** Retry attempt details */ attemptDetails: Array<{ attempt: number; durationMs: number; error?: unknown; delayMs?: number; }>; } /** * Retry manager class for handling retries with exponential backoff */ export declare class RetryManager { /** * Execute an operation with retry logic */ withRetry<T>(operation: () => Promise<T>, config?: Partial<RetryConfig>): Promise<T>; /** * Create a delay promise */ private delay; /** * Create an enhanced error with retry context */ private createRetryFailureError; /** * Generate user-friendly guidance based on the error pattern */ private generateUserGuidance; } /** * Global retry manager instance */ export declare const globalRetryManager: RetryManager; /** * Convenience function for wrapping operations with retry logic */ export declare function withRetry<T>(operation: () => Promise<T>, toolName: string, config?: Partial<RetryConfig>): Promise<T>; /** * Check if an error is retryable based on common patterns */ export declare function isRetryableError(error: unknown): boolean; /** * Create retry-aware timeout wrapper that combines timeout and retry logic * This function properly manages timeout budgets to prevent retry delays from * exceeding total operation time limits. */ export declare function withRetryAndTimeout<T>(operation: () => Promise<T>, toolName: string, retryConfig?: Partial<RetryConfig>, totalTimeoutMs?: number): Promise<T>; //# sourceMappingURL=retry-manager.d.ts.map