UNPKG

@sidequest/engine

Version:

@sidequest/engine is the core engine of SideQuest, a distributed background job processing system for Node.js and TypeScript.

40 lines (37 loc) 1.31 kB
import { ScheduledTask } from 'node-cron'; /** * A registry for tracking and managing scheduled cron jobs. * This allows centralized control over all scheduled tasks for proper cleanup. */ declare class ScheduledJobRegistry { private static scheduledTasks; /** * Register a scheduled task in the registry. * @param task - The scheduled task to register * @returns A unique task ID for the registered task */ static register(task: ScheduledTask): string; /** * Unregister and stop a specific scheduled task. * @param taskId - The ID of the task to unregister * @returns True if the task was found and stopped, false otherwise */ static stop(taskId: string): Promise<boolean>; /** * Stop and unregister all scheduled tasks. * This should be called during application shutdown to ensure proper cleanup. */ static stopAll(): Promise<void>; /** * Get the number of registered tasks. * @returns The count of registered tasks */ static getTaskCount(): number; /** * Check if a task is registered. * @param taskId - The ID of the task to check * @returns True if the task is registered, false otherwise */ static hasTask(taskId: string): boolean; } export { ScheduledJobRegistry };