torotask
Version:
Task queue processing in NodeJS based on BullMQ and Redis
42 lines • 2.14 kB
TypeScript
import type { Job } from 'bullmq';
import type { Logger } from 'pino';
import type { ToroTask } from './client.js';
import type { BulkJob, TaskJobData, TaskJobOptions, TaskJobState, TaskQueueOptions } from './types/index.js';
import { Queue } from 'bullmq';
import { TaskJob } from './job.js';
export declare class TaskQueue<PayloadType = any, ResultType = any, NameType extends string = string, const DataType extends TaskJobData = TaskJobData<PayloadType>> extends Queue<any, ResultType, NameType> {
readonly taskClient: ToroTask;
readonly logger: Logger;
constructor(taskClient: ToroTask, name: string, options?: Partial<TaskQueueOptions>);
/**
* Overrides the default BullMQ `Job` class with the custom `TaskJob` class.
* This ensures that jobs created and retrieved from this queue are instances of `TaskJob`,
* providing access to custom properties and methods.
*
* @returns The `TaskJob` class constructor.
*/
protected get Job(): typeof Job;
protected get TaskJob(): typeof TaskJob<PayloadType, ResultType, NameType>;
/**
* Get the Redis client instance used by the queue.
* @returns The Redis client instance.
*/
getRedisClient(): Promise<import("bullmq").RedisClient>;
/**
* Core logic to add a job to the queue.
* Public method intended for use by subclasses or related classes (e.g., SubTask).
*/
add(name: NameType, payload: PayloadType, options?: TaskJobOptions, state?: TaskJobState): Promise<TaskJob<PayloadType, ResultType, NameType>>;
/**
* Core logic to add multiple jobs to the queue.
* Public method intended for use by subclasses or related classes (e.g., SubTask).
*/
addBulk(jobs: BulkJob<DataType>[]): Promise<TaskJob<PayloadType, ResultType>[]>;
/**
* Core logic to add a job and wait for its completion.
* Public method intended for use by subclasses or related classes.
*/
_runJobAndWait(name: NameType, payload: PayloadType, options: TaskJobOptions, state?: TaskJobState): Promise<ResultType>;
protected queueEvents?: any;
}
//# sourceMappingURL=queue.d.ts.map