deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
75 lines (74 loc) • 2.39 kB
TypeScript
/**
* @fileoverview Retry policy configuration for DeepSource MCP Server
* This module defines retry policies and configuration for automatic retries.
*/
import { ErrorCategory } from '../errors/categories.js';
/**
* Retry policy configuration for API operations
* @interface
* @public
*/
export interface RetryPolicy {
/** Maximum number of retry attempts */
maxAttempts: number;
/** Base delay in milliseconds for exponential backoff */
baseDelay: number;
/** Maximum delay in milliseconds */
maxDelay: number;
/** Jitter factor (0-1) for randomization */
jitterFactor: number;
/** Error categories that should trigger a retry */
retriableErrors: ErrorCategory[];
/** Whether to respect Retry-After headers */
respectRetryAfter: boolean;
/** Policy name for logging */
name: string;
}
/**
* Retry policy presets
* @enum
* @public
*/
export declare enum RetryPolicyType {
/** Aggressive retry for critical read operations */
AGGRESSIVE = "aggressive",
/** Standard retry for normal operations */
STANDARD = "standard",
/** Cautious retry for sensitive operations */
CAUTIOUS = "cautious",
/** No retry for mutations */
NONE = "none"
}
/**
* Predefined retry policies for different operation types
* @public
*/
export declare const RETRY_POLICIES: Record<RetryPolicyType, RetryPolicy>;
/**
* Map of endpoint patterns to retry policies
* Used to determine which policy to apply for a given operation
* @public
*/
export declare const ENDPOINT_POLICIES: Map<string, RetryPolicyType>;
/**
* Get retry policy for a given endpoint
* @param endpoint The endpoint or operation name
* @returns The appropriate retry policy
* @public
*/
export declare function getRetryPolicyForEndpoint(endpoint: string): RetryPolicy;
/**
* Check if an error category is retriable according to a policy
* @param errorCategory The error category to check
* @param policy The retry policy to check against
* @returns True if the error is retriable
* @public
*/
export declare function isRetriableByPolicy(errorCategory: ErrorCategory, policy: RetryPolicy): boolean;
/**
* Create a custom retry policy
* @param options Partial policy options to override defaults
* @returns A new retry policy
* @public
*/
export declare function createCustomPolicy(options: Partial<RetryPolicy>): RetryPolicy;