UNPKG

torotask

Version:

Task queue processing in NodeJS based on BullMQ and Redis

46 lines 2.62 kB
import { ToroTask } from './client.js'; import { TaskJob } from './job.js'; import { TaskQueueEvents } from './queue-events.js'; import { TaskQueue } from './queue.js'; import type { TaskWorkerQueueListener, TaskWorkerQueueOptions, TaskWorkerOptions } from './types/index.js'; import { TaskWorker } from './worker.js'; export declare class TaskWorkerQueue<PayloadType = any, ResultType = any, NameType extends string = string> extends TaskQueue<PayloadType, ResultType, NameType> { options?: Partial<TaskWorkerQueueOptions<PayloadType, ResultType, NameType>> | undefined; readonly queueEvents: TaskQueueEvents; workerOptions: Partial<TaskWorkerOptions> | undefined; protected worker?: TaskWorker<PayloadType, ResultType, NameType> | undefined; private workerEventHandlers; constructor(taskClient: ToroTask, name: string, options?: Partial<TaskWorkerQueueOptions<PayloadType, ResultType, NameType>> | undefined); /** * Method to process a job. * Subclasses must implement this method to define the job handling logic. * * @param job The BullMQ job object. * @returns A promise that resolves with the result of the job. */ process(_job: TaskJob<PayloadType, ResultType, NameType>, _token?: string): Promise<ResultType>; getWorkerOptions(): Partial<TaskWorkerOptions>; /** * Starts a dedicated BullMQ Worker for this queue, if one is not already running. * Forwards worker events to this BaseQueue instance, prefixing them with 'worker:'. */ startWorker(options?: TaskWorkerOptions): Promise<TaskWorker<PayloadType, ResultType, NameType>>; /** Helper to remove all attached worker listeners */ private removeAllWorkerListeners; /** * Stops the worker instance associated with this queue, if it is running. * Removes event listeners before closing. */ stopWorker(): Promise<void>; /** * Closes the underlying BullMQ Worker (if started), Queue, and QueueEvents instances, * and removes the instance from the static registry. * Should be called during application shutdown. */ close(): Promise<void>; emit<U extends keyof TaskWorkerQueueListener>(event: U, ...args: Parameters<TaskWorkerQueueListener[U]>): boolean; off<U extends keyof TaskWorkerQueueListener>(eventName: U, listener: TaskWorkerQueueListener[U]): this; on<U extends keyof TaskWorkerQueueListener>(event: U, listener: TaskWorkerQueueListener[U]): this; once<U extends keyof TaskWorkerQueueListener>(event: U, listener: TaskWorkerQueueListener[U]): this; } //# sourceMappingURL=worker-queue.d.ts.map