UNPKG

@push.rocks/smartproxy

Version:

A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.

48 lines (47 loc) 1.36 kB
import * as plugins from '../../plugins.js'; import { type IHttpProxyOptions } from './models/types.js'; /** * Manages a pool of backend connections for efficient reuse */ export declare class ConnectionPool { private options; private connectionPool; private roundRobinPositions; private logger; constructor(options: IHttpProxyOptions); /** * Get a connection from the pool or create a new one */ getConnection(host: string, port: number): Promise<plugins.net.Socket>; /** * Return a connection to the pool for reuse */ returnConnection(socket: plugins.net.Socket, host: string, port: number): void; /** * Cleanup the connection pool by removing idle connections * or reducing pool size if it exceeds the configured maximum */ cleanupConnectionPool(): void; /** * Close all connections in the pool */ closeAllConnections(): void; /** * Get load balancing target using round-robin */ getNextTarget(targets: string[], port: number): { host: string; port: number; }; /** * Gets the connection pool status */ getPoolStatus(): Record<string, { total: number; idle: number; }>; /** * Setup a periodic cleanup task */ setupPeriodicCleanup(interval?: number): NodeJS.Timeout; }