UNPKG

torotask

Version:

Task queue processing in NodeJS based on BullMQ and Redis

36 lines 1.92 kB
import type { WorkerOptions } from 'bullmq'; import type { TaskGroupDefinitionRegistry, TaskGroupRegistry, TaskServerOptions, WorkerFilterGroups } from './types/index.js'; import { ToroTask } from './client.js'; /** * A server class responsible for managing the lifecycle of BullMQ workers * based on TaskGroup definitions from the client package. * Provides features like centralized worker start/stop and optional global error handling. * * @template TAllTaskGroupsDefs The type of all task group definitions provided to the server * @template TGroups The type of task groups derived from the task group definitions */ export declare class TaskServer<TAllTaskGroupsDefs extends TaskGroupDefinitionRegistry = TaskGroupDefinitionRegistry, TGroups extends TaskGroupRegistry<TAllTaskGroupsDefs> = TaskGroupRegistry<TAllTaskGroupsDefs>> extends ToroTask<TAllTaskGroupsDefs> { readonly options: TaskServerOptions; private unhandledRejectionListener?; private uncaughtExceptionListener?; constructor(options: TaskServerOptions, taskGroupDefs?: TAllTaskGroupsDefs); /** * Starts server and workers based on the provided filter. * * @param filter Optional filter to target specific groups or tasks. * @param workerOptions Optional default WorkerOptions to pass down. */ start(filter?: WorkerFilterGroups<TGroups>, workerOptions?: WorkerOptions): Promise<void>; /** * Stops server and workers based on the provided filter. * * @param filter Optional filter to target specific groups or tasks. * @returns A promise that resolves when all targeted workers have been requested to stop. */ stop(filter?: WorkerFilterGroups<TGroups>): Promise<void>; private attachGlobalErrorHandlers; private detachGlobalErrorHandlers; private handleUnhandledRejection; private handleUncaughtException; } //# sourceMappingURL=server.d.ts.map