@sandsoftwaresolutions/job-queue
v0.1.0
Published
Small in-memory promise job queue with concurrency and retries.
Maintainers
Readme
@sandsoftwaresolutions/job-queue
A tiny promise queue for controlled concurrent work in Node.js scripts, workers and API processes.
Install
npm install @sandsoftwaresolutions/job-queueUsage
import { JobQueue } from "@sandsoftwaresolutions/job-queue";
const queue = new JobQueue({ concurrency: 4 });
const results = await Promise.all(customers.map((customer) =>
queue.add(() => sendEmail(customer), { retries: 2 })
));
await queue.onIdle();API
new JobQueue({ concurrency = 1 })sets the maximum number of active jobs.queue.add(task, { retries = 0 })schedules a function and returns its result as a promise.queue.onIdle()resolves once all pending and active work has finished.
Retries happen immediately after a failure. This queue intentionally stores work only in memory: a restart loses queued jobs. Use a durable broker for payments, emails, or other work that must survive a crash.
