49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
|
|
/**
|
||
|
|
* SMTP Client Connection Manager
|
||
|
|
* Connection pooling and lifecycle management
|
||
|
|
*/
|
||
|
|
import { EventEmitter } from 'node:events';
|
||
|
|
import type { ISmtpClientOptions, ISmtpConnection, IConnectionPoolStatus } from './interfaces.js';
|
||
|
|
export declare class ConnectionManager extends EventEmitter {
|
||
|
|
private options;
|
||
|
|
private connections;
|
||
|
|
private pendingConnections;
|
||
|
|
private idleTimeout;
|
||
|
|
constructor(options: ISmtpClientOptions);
|
||
|
|
/**
|
||
|
|
* Get or create a connection
|
||
|
|
*/
|
||
|
|
getConnection(): Promise<ISmtpConnection>;
|
||
|
|
/**
|
||
|
|
* Create a new connection
|
||
|
|
*/
|
||
|
|
createConnection(): Promise<ISmtpConnection>;
|
||
|
|
/**
|
||
|
|
* Release a connection back to the pool or close it
|
||
|
|
*/
|
||
|
|
releaseConnection(connection: ISmtpConnection): void;
|
||
|
|
/**
|
||
|
|
* Close a specific connection
|
||
|
|
*/
|
||
|
|
closeConnection(connection: ISmtpConnection): void;
|
||
|
|
/**
|
||
|
|
* Close all connections
|
||
|
|
*/
|
||
|
|
closeAllConnections(): void;
|
||
|
|
/**
|
||
|
|
* Get connection pool status
|
||
|
|
*/
|
||
|
|
getPoolStatus(): IConnectionPoolStatus;
|
||
|
|
/**
|
||
|
|
* Update connection activity timestamp
|
||
|
|
*/
|
||
|
|
updateActivity(connection: ISmtpConnection): void;
|
||
|
|
private establishSocket;
|
||
|
|
private setupSocketHandlers;
|
||
|
|
private findIdleConnection;
|
||
|
|
private shouldReuseConnection;
|
||
|
|
private getActiveConnectionCount;
|
||
|
|
private getConnectionId;
|
||
|
|
private setupIdleCleanup;
|
||
|
|
}
|