UNPKG

@lexamica-modules/job-queue

Version:

The package for the Lexamica Job Queue SDK powered by Redis and BullMQ

28 lines (27 loc) 1.15 kB
import { Worker } from "bullmq"; import { JobExecuter, WorkerCompleteHandler, WorkerErrorHandler, WorkerFailedHandler, WorkerOptions } from "../types"; import { Redis } from "ioredis"; /** * Management class for all Workers */ export declare class Workers { private _connection; /** * Initialize an instance of the Worker Management Class * @param {Redis} connection the Redis connection to use */ constructor(connection: Redis); /** * Add a worker to a given queue with an executer function * @param {string} queue_name the name of the queue to add this worker to * @param {JobExecuter} executer function to execute when processing jobs * @returns {Worker} */ addWorker: (queue_name: string, executer: JobExecuter, options: WorkerOptions, onCompleted?: WorkerCompleteHandler, onFailed?: WorkerFailedHandler, onError?: WorkerErrorHandler) => Worker; /** * Finish the worker's current job and then pause it from processing more jobs. * @param {Worker} worker the worker instance * @returns {Promise<void>} */ closeWorker: (worker: Worker) => Promise<void>; }