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.

37 lines (36 loc) 1.36 kB
import { TasksQueueDao } from "./tasks-queue.dao.js"; import { TasksWorker } from "./tasks-worker.js"; import { Clock } from "./clock.js"; export declare class TasksQueueWorker { private readonly tasksQueueDao; private readonly clock; private readonly poolName; private readonly workers; private readonly pipeline; private started; private readonly queueNotifier; constructor(tasksQueueDao: TasksQueueDao, concurrency?: number, loopInterval?: number, clock?: Clock, queueNotifier?: (queueName: string) => void, poolName?: string); start(): void; stop(): Promise<void>; runOnce(): Promise<void>; registerWorker(queueName: string, worker: TasksWorker): void; tasksScheduled(queueName: string): void; /** * Wake a blocked parent task after a child has reached a terminal state and notify its queue. * * @param childTaskId child task id */ private wakeBlockedParent; private pollNextTask; private updatePoolQueuesLabel; /** * Persist a successful task outcome based on runtime orchestration state. * * The method handles child spawning, one-time task finishing, and periodic rescheduling. * * @param task current scheduled task * @param context runtime task context */ private persistSuccessfulOutcome; private processNextTask; }