This app demonstrates how to use @goodware/task-queue from TypeScript to:
- limit concurrency with
workers - cap queued work with
size - apply simple backpressure with
queue.full - wait for task completion through the
promisereturned bypush()
It runs directly on Node 24+ using Node's built-in TypeScript support, so there is no extra TypeScript runtime dependency in this example.
npm startOverride backfill queue size and max concurrency:
npm start -- --size 20 --workers 5For auto-reload while iterating:
npm run devCLI flags:
--size <number>: maximum queue size used for backfill pressure control (default:4)--workers <number>: maximum concurrent workers (default:2)--help: show usage
The example simulates importing 60 customer jobs. It uses:
- configurable
workersso only that many jobs execute at the same time - configurable
sizeso only that many jobs are in-flight (running/queued in the queue) - basic backpressure with
queue.fullbefore submitting more work - periodic failures (
jobId % 15 === 0) to demonstrate per-job error handling
At the end of each run, it prints:
- total jobs processed
- each job's elapsed time in milliseconds
- maximum concurrency observed
- average (time-weighted) concurrency
- total backpressure wait time
- total runtime for the full script