import TaskManager from './TaskManager.js'; /** * TaskManagerRegistry * * A singleton registry to track active TaskManager instances, keyed by `jobId`. * * In a system where jobs are processed via isolated TaskManager instances, * this registry provides global visibility and control over running jobs * without violating encapsulation or spawning duplicates. * * --------------------------------------------------------------------------------------- * ✅ WHY THIS EXISTS: * --------------------------------------------------------------------------------------- * - Each `TaskManager` is designed to handle a single job at a time. * - The API (or other system components) should not create new instances blindly. * - Instead, they can **query the registry** for the job-specific TaskManager. * - This avoids duplicate execution and lets the system safely: * - Pause/resume/stop jobs * - Fetch logs or live state * - Broadcast updates via WebSocket * * --------------------------------------------------------------------------------------- * FUTURE USE CASES: * --------------------------------------------------------------------------------------- * - **Parallel Job Execution:** * You’ll eventually support multiple jobs running at the same time (concurrently). * This registry is the backbone for that. Each job gets its own `TaskManager`, * but the registry keeps them accessible and uniquely identifiable. * * - **Safe Shutdown / Cleanup:** * On server shutdown, loop through all managers via the registry * and gracefully shut down active tasks. * * - Use `.register()` when starting a job * - Use `.remove()` once the job finishes (success/fail) * - `.get()` to safely access a manager by ID * - Singleton ensures the same instance is used everywhere */ export declare class TaskManagerRegistry { private static instance; private registry; private constructor(); static getInstance(): TaskManagerRegistry; register(jobId: string, manager: TaskManager): void; get(jobId: string): TaskManager | undefined; remove(jobId: string): void; /** Jobs with a task manager, which is to say the jobs this node is running. */ size(): number; has(jobId: string): boolean; stop(): Promise; }