@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.
49 lines (48 loc) • 1.62 kB
TypeScript
import type { IConnectionRecord } from './models/interfaces.js';
import type { SmartProxy } from './smart-proxy.js';
/**
* Manages timeouts and inactivity tracking for connections
*/
export declare class TimeoutManager {
private smartProxy;
constructor(smartProxy: SmartProxy);
/**
* Ensure timeout values don't exceed Node.js max safe integer
*/
ensureSafeTimeout(timeout: number): number;
/**
* Generate a slightly randomized timeout to prevent thundering herd
*/
randomizeTimeout(baseTimeout: number, variationPercent?: number): number;
/**
* Update connection activity timestamp
*/
updateActivity(record: IConnectionRecord): void;
/**
* Calculate effective inactivity timeout based on connection type
*/
getEffectiveInactivityTimeout(record: IConnectionRecord): number;
/**
* Calculate effective max lifetime based on connection type
*/
getEffectiveMaxLifetime(record: IConnectionRecord): number;
/**
* Setup connection timeout
* @returns The cleanup timer
*/
setupConnectionTimeout(record: IConnectionRecord, onTimeout: (record: IConnectionRecord, reason: string) => void): NodeJS.Timeout | null;
/**
* Check for inactivity on a connection
* @returns Object with check results
*/
checkInactivity(record: IConnectionRecord): {
isInactive: boolean;
shouldWarn: boolean;
inactivityTime: number;
effectiveTimeout: number;
};
/**
* Apply socket timeout settings
*/
applySocketTimeouts(record: IConnectionRecord): void;
}