UNPKG

nodejs-cloud-taskmq

Version:

Node.js TypeScript library for integrating Google Cloud Tasks with MongoDB/Redis/Memory/Custom for a BullMQ-like queue system. Compatible with NestJS but framework-agnostic.

55 lines (54 loc) 1.4 kB
import 'reflect-metadata'; /** * Metadata key for processor decorators */ export declare const PROCESSOR_QUEUE_KEY = "cloud_taskmq:processor_queue"; /** * Metadata key for processor metadata */ export declare const PROCESSOR_METADATA_KEY = "cloud_taskmq:processor_metadata"; /** * Processor options */ export interface ProcessorOptions { /** * Concurrency limit (how many tasks can be processed simultaneously) */ concurrency?: number; /** * Custom handler name (if different than the method name) */ name?: string; /** * Queue-specific options */ queueOptions?: { /** * Maximum number of retries for failed tasks */ maxRetries?: number; /** * Retry delay in seconds */ retryDelay?: number; }; } /** * Marks a class as a task processor for a specific queue. * This processor will handle tasks from the specified queue name. * * @param queueName Name of the queue to process tasks from * @param options Additional processor options * * @example * ```typescript * @Processor('email-queue') * export class EmailProcessor { * @Process() * async handleEmailTask(job: CloudTask<EmailData>) { * // Process the email task * } * } * ``` */ export declare function Processor(queueName: string, options?: ProcessorOptions): (target: any) => void;