UNPKG

amazon-seller-mcp

Version:

Model Context Protocol (MCP) client for Amazon Selling Partner API

154 lines (153 loc) 3.32 kB
/** * Connection pool manager for Amazon Seller MCP Client * * This file implements connection pooling for HTTP requests to improve performance: * - Reuse HTTP connections * - Limit concurrent connections * - Connection timeout management * - Connection health monitoring */ import http from 'http'; import https from 'https'; /** * Connection pool configuration */ export interface ConnectionPoolConfig { /** * Maximum number of sockets per host * @default 10 */ maxSockets?: number; /** * Maximum number of free sockets to keep alive * @default 5 */ maxFreeSockets?: number; /** * Socket timeout in milliseconds * @default 60000 (1 minute) */ timeout?: number; /** * Keep-alive timeout in milliseconds * @default 60000 (1 minute) */ keepAliveTimeout?: number; /** * Whether to enable connection reuse * @default true */ keepAlive?: boolean; } /** * Connection pool statistics */ interface ConnectionPoolStats { /** * Number of active sockets */ activeSockets: number; /** * Number of free sockets */ freeSockets: number; /** * Number of queued requests */ queuedRequests: number; /** * Total number of requests */ totalRequests: number; /** * Total number of timeouts */ timeouts: number; /** * Total number of errors */ errors: number; } /** * Connection pool manager for HTTP requests */ export declare class ConnectionPool { /** * HTTP agent for connection pooling */ private httpAgent; /** * HTTPS agent for connection pooling */ private httpsAgent; /** * Connection pool configuration */ private config; /** * Connection pool statistics */ private stats; /** * Create a new connection pool * * @param config Connection pool configuration */ constructor(config?: ConnectionPoolConfig); /** * Get the HTTP agent * * @returns HTTP agent */ getHttpAgent(): http.Agent; /** * Get the HTTPS agent * * @returns HTTPS agent */ getHttpsAgent(): https.Agent; /** * Get connection pool statistics * * @returns Connection pool statistics */ getStats(): ConnectionPoolStats; /** * Update connection pool statistics */ private updateStats; /** * Start monitoring connections */ private startMonitoring; /** * Monitor socket events */ private monitorSocketEvents; /** * Track a new request */ trackRequest(): void; /** * Close all connections */ destroy(): void; } /** * Configure the default connection pool * * @param config Connection pool configuration */ export declare function configureConnectionPool(config: ConnectionPoolConfig): void; /** * Get the default connection pool instance * * @returns Default connection pool instance */ export declare function getConnectionPool(): ConnectionPool; declare const _default: { ConnectionPool: typeof ConnectionPool; configureConnectionPool: typeof configureConnectionPool; getConnectionPool: typeof getConnectionPool; }; export default _default;