@sidequest/engine
Version:
@sidequest/engine is the core engine of SideQuest, a distributed background job processing system for Node.js and TypeScript.
46 lines (43 loc) • 1.35 kB
TypeScript
import { Backend } from '@sidequest/backend';
import { ExecutorManager } from './executor-manager.js';
import { QueueManager } from './queue-manager.js';
/**
* Dispatcher for managing job execution and queue polling.
*/
declare class Dispatcher {
private backend;
private queueManager;
private executorManager;
private sleepDelay;
/** Indicates if the dispatcher is currently running */
private isRunning;
/**
* Creates a new Dispatcher.
* @param backend The backend instance.
* @param queueManager The queue manager instance.
* @param executorManager The executor manager instance.
*/
constructor(backend: Backend, queueManager: QueueManager, executorManager: ExecutorManager, sleepDelay: number);
/**
* Main loop for polling queues and dispatching jobs.
* @private
*/
private listen;
/**
* Sleeps for the given delay in milliseconds.
* @param delay The delay in milliseconds.
* @returns A promise that resolves after the delay.
* @private
*/
private sleep;
/**
* Starts the dispatcher loop.
*/
start(): void;
/**
* Stops the dispatcher and waits for all active jobs to finish.
* @returns A promise that resolves when all jobs are finished.
*/
stop(): Promise<void>;
}
export { Dispatcher };