@andrew_eragon/mcp-server-salesforce
Version:
A SaaS-ready Salesforce connector MCP Server with connection pooling and multi-user support.
55 lines (54 loc) • 1.55 kB
TypeScript
/**
* Utilities for parallel execution and rate limiting
*/
/**
* Execute promises with concurrency limit
*/
export declare function parallelLimit<T, R>(items: T[], concurrency: number, fn: (item: T) => Promise<R>): Promise<R[]>;
/**
* Batch items and process in parallel
*/
export declare function batchProcess<T, R>(items: T[], batchSize: number, fn: (batch: T[]) => Promise<R[]>): Promise<R[]>;
/**
* Rate limiter
*/
export declare class RateLimiter {
private queue;
private currentRequests;
private readonly maxRequests;
private readonly timeWindow;
private requestTimestamps;
/**
* @param maxRequests Maximum number of requests
* @param timeWindow Time window in milliseconds
*/
constructor(maxRequests: number, timeWindow: number);
/**
* Execute function with rate limiting
*/
execute<T>(fn: () => Promise<T>): Promise<T>;
private waitForSlot;
private releaseSlot;
/**
* Get current rate limit status
*/
getStatus(): {
current: number;
max: number;
available: number;
};
}
/**
* Retry function with exponential backoff
*/
export declare function retry<T>(fn: () => Promise<T>, options?: {
maxAttempts?: number;
initialDelay?: number;
maxDelay?: number;
backoffMultiplier?: number;
onRetry?: (error: Error, attempt: number) => void;
}): Promise<T>;
/**
* Timeout wrapper for promises
*/
export declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage?: string): Promise<T>;