UNPKG

github-pr-automation

Version:

MCP server and CLI for automated GitHub PR management, review resolution, and workflow optimization

80 lines 2.28 kB
/** * GitHub API rate limiting and backoff * * Implements exponential backoff and request queuing to respect * GitHub's rate limits and avoid 429 errors. */ export interface RateLimitInfo { limit: number; remaining: number; reset: number; used: number; } export interface QueuedRequest { id: string; fn: () => Promise<unknown>; resolve: (value: unknown) => void; reject: (error: Error) => void; priority: "high" | "normal" | "low"; timestamp: number; } /** * GitHub API rate limiter with exponential backoff * * Manages request queuing and rate limiting to respect GitHub's * API limits and implement proper backoff strategies. */ export declare class RateLimiter { private queue; private isProcessing; private currentLimit; private backoffUntil; /** * Update rate limit info from GitHub API response headers */ updateRateLimit(headers: Record<string, string>): void; /** * Check if we can make a request now * @returns true if request can be made immediately, false otherwise */ canMakeRequest(): boolean; /** * Calculate backoff delay based on remaining requests * @returns Backoff delay in milliseconds */ private calculateBackoff; /** * Queue a request for execution */ queueRequest<T>(fn: () => Promise<T>, priority?: "high" | "normal" | "low"): Promise<T>; /** * Find the correct position to insert request based on priority * @param request - Request to find insertion point for * @returns Index where request should be inserted */ private findInsertIndex; /** * Process the request queue */ private processQueue; /** * Sleep for specified milliseconds * @param ms - Milliseconds to sleep * @returns Promise that resolves after the specified time */ private sleep; /** * Get current queue status * @returns Object containing queue length and priority distribution */ getQueueStatus(): { length: number; priorities: Record<string, number>; }; /** * Clear all queued requests */ clearQueue(): void; } export declare const rateLimiter: RateLimiter; //# sourceMappingURL=rate-limiter.d.ts.map