/** * Centralized Cleanup Manager * * Manages cleanup intervals and background tasks across all components * to prevent memory leaks and ensure proper resource management. */ import { EventEmitter } from 'events'; export interface CleanupTask { id: string; name: string; interval: NodeJS.Timeout; cleanup: () => void | Promise; frequency: number; lastRun: number; runCount: number; enabled: boolean; component: string; } export interface CleanupManagerConfig { defaultCleanupInterval?: number; maxTaskAge?: number; enableMetrics?: boolean; healthCheckInterval?: number; } export interface CleanupMetrics { totalTasks: number; activeTasks: number; completedCleanups: number; failedCleanups: number; averageCleanupTime: number; lastCleanupTime: number; memoryFreed: number; } /** * Centralized cleanup manager for all background tasks */ export declare class CleanupManager extends EventEmitter { private config; private tasks; private metrics; private healthCheckInterval?; private isShutdown; private componentTasks; constructor(config?: CleanupManagerConfig); /** * Register a cleanup task */ registerTask(id: string, name: string, cleanup: () => void | Promise, options?: { frequency?: number; component?: string; enabled?: boolean; }): void; /** * Unregister a cleanup task */ unregisterTask(id: string): void; /** * Enable or disable a task */ setTaskEnabled(id: string, enabled: boolean): void; /** * Execute a specific cleanup task */ executeTask(id: string): Promise; /** * Execute all tasks for a specific component */ executeComponentTasks(component: string): Promise; /** * Execute all enabled tasks */ executeAllTasks(): Promise; /** * Get task information */ getTask(id: string): CleanupTask | undefined; /** * Get all tasks */ getAllTasks(): CleanupTask[]; /** * Get tasks for a specific component */ getComponentTasks(component: string): CleanupTask[]; /** * Get cleanup metrics */ getMetrics(): CleanupMetrics; /** * Get component summary */ getComponentSummary(): Record; /** * Force cleanup of old or stale tasks */ forceCleanup(): Promise; /** * Shutdown the cleanup manager */ shutdown(): Promise; /** * Start health check monitoring */ private ensureHealthChecksStarted; private startHealthChecks; /** * Perform health check on all tasks */ private performHealthCheck; /** * Get recent task executions (simplified tracking) */ private getRecentTaskExecutions; /** * Update cleanup metrics */ private updateCleanupMetrics; } /** * Global cleanup manager instance */ export declare const globalCleanupManager: CleanupManager; /** * Create a cleanup manager with custom configuration */ export declare function createCleanupManager(config?: CleanupManagerConfig): CleanupManager; export default CleanupManager; //# sourceMappingURL=cleanupManager.d.ts.map