https://github.com/imqueue/job
Simple job queue
https://github.com/imqueue/job
Last synced: 9 months ago
JSON representation
Simple job queue
- Host: GitHub
- URL: https://github.com/imqueue/job
- Owner: imqueue
- License: isc
- Created: 2020-11-20T22:19:52.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-09T07:30:51.000Z (about 2 years ago)
- Last Synced: 2024-10-16T00:32:06.522Z (about 1 year ago)
- Language: TypeScript
- Size: 271 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple Job Queue (@imqueue/job)
[](https://travis-ci.org/imqueue/job)
[](https://snyk.io/test/github/imqueue/job?targetFile=package.json)
[](https://rawgit.com/imqueue/core/master/LICENSE)
Simple job queue using JSON messaging for managing backand background jobs.
Backed up by Redis.
# Features
Based on @imqueue/core it provides Job Queue functionality including:
- **Safe job processing** - no data loss!
- **Fast processing** - by events, not timers, low resource usage.
- **Supports gzip compression** for job data (decrease traffic usage, but
slower).
- **Concurrent workers model supported**, the same queue can have multiple
consumers with no data loss and natural load-balancing.
- **Scheduleable jobs** - jobs can be delayed by specified time,
granularity - milliseconds.
- **Job expiration supported** - job can live forever or specified time,
granularity - milliseconds.
- **Publisher/Worker/Both** models of work with queues supported.
- **TypeScript included!**
# Requirements
See requirements for @imqueue/core
# Install
~~~bash
npm i --save @imqueue/job
~~~
# Usage
~~~typescript
import JobQueue, { JobQueuePublisher, JobQueueWorker } from '@imqueue/job';
// Standard job queue (both - worker and publisher) example
new JobQueue({ name: 'TestJob' })
.onPop(job => console.log(job))
.start().then(queue => queue
.push('Hello, world!')
.push('Hello, world after 1 sec!', { delay: 1000 })
.push('Hello, world after 2 sec!', { delay: 2000 })
.push('Hello, world after 5 sec!', { delay: 5000 })
.push('Hello, world after 10 sec!', { delay: 10000 }),
);
// Job queue publisher-only example
new JobQueuePublisher({ name: 'CustomTestJob' })
.start().then(queue => queue
.push('Hello, job world!')
.push('Hello, job world after 1 sec!', { delay: 1000 })
.push('Hello, job world after 2 sec!', { delay: 2000 })
.push('Hello, job world after 5 sec!', { delay: 5000 })
.push('Hello, job world after 10 sec!', { delay: 10000 }),
);
// Job queue worker only example
new JobQueueWorker({ name: 'CustomTestJob' })
.onPop(job => console.log(job))
.start()
.catch(err => console.error(err));
~~~
## License
[ISC](https://rawgit.com/imqueue/job/master/LICENSE)