UNPKG

@penkov/tasks_queue

Version:

A lightweight PostgreSQL-backed task queue system with scheduling, retries, backoff strategies, and priority handling. Designed for efficiency and observability in modern Node.js applications.

17 lines (16 loc) 788 B
import "reflect-metadata"; export const TASKS_QUEUE_SCHEDULED_TASK_METADATA = Symbol("tasks-queue-scheduled-task-metadata"); export const ScheduledTask = (options) => (_target, _propertyKey, descriptor) => { if (typeof descriptor.value !== "function") { throw new Error("@ScheduledTask decorator can only be applied to methods"); } const scheduleVariants = [ options.cron !== undefined, options.fixedRate !== undefined, options.fixedDelay !== undefined, ].filter((v) => v).length; if (scheduleVariants !== 1) { throw new Error("@ScheduledTask requires exactly one schedule field: 'cron', 'fixedRate', or 'fixedDelay'"); } Reflect.defineMetadata(TASKS_QUEUE_SCHEDULED_TASK_METADATA, { ...options }, descriptor.value); };