UNPKG

@sidequest/engine

Version:

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

31 lines (28 loc) 931 B
import { JobData, JobResult } from '@sidequest/core'; import EventEmitter from 'events'; import { NonNullableEngineConfig } from '../engine.js'; /** * A pool of worker threads for running jobs in parallel using Piscina. */ declare class RunnerPool { private nonNullConfig; /** The underlying Piscina worker pool. */ private readonly pool; /** * Creates a new RunnerPool. * @param nonNullConfig The non-nullable engine configuration. */ constructor(nonNullConfig: NonNullableEngineConfig); /** * Runs a job in the worker pool. * @param job The job data to run. * @param signal Optional event emitter for cancellation. * @returns A promise resolving to the job result. */ run(job: JobData, signal?: EventEmitter): Promise<JobResult>; /** * Destroys the worker pool and releases resources. */ destroy(): Promise<void>; } export { RunnerPool };