UNPKG

@sidequest/engine

Version:

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

55 lines (52 loc) 1.76 kB
import { Backend } from '@sidequest/backend'; import { QueueConfig, JobData } from '@sidequest/core'; import { NonNullableEngineConfig } from '../engine.js'; /** * Manages job execution and worker concurrency for Sidequest. */ declare class ExecutorManager { private backend; private nonNullConfig; private activeByQueue; private activeJobs; private runnerPool; /** * Creates a new ExecutorManager. * @param backend The backend instance. * @param nonNullConfig The non-nullable engine configuration. */ constructor(backend: Backend, nonNullConfig: NonNullableEngineConfig); /** * Gets the number of available slots for a given queue. * @param queueConfig The queue configuration. * @returns The number of available slots. */ availableSlotsByQueue(queueConfig: QueueConfig): number; /** * Gets the number of available slots globally. * @returns The number of available slots. */ availableSlotsGlobal(): number; /** * Gets the total number of active workers. * @returns The number of active jobs. */ totalActiveWorkers(): number; /** * Prepares a job for execution by marking it as active and adding it to a queue slot. * @param queueConfig The queue configuration. * @param job The job data. */ queueJob(queueConfig: QueueConfig, job: JobData): void; /** * Executes a job in the given queue. * @param queueConfig The queue configuration. * @param job The job data to execute. */ execute(queueConfig: QueueConfig, job: JobData): Promise<void>; /** * Destroys the runner pool and releases resources. */ destroy(): Promise<void>; } export { ExecutorManager };