xque
v0.0.8
Published
A redis-based job queue library written in typescript that supports retries, job priorities and expiration.
Readme
xque
A redis-based job queue library written in typescript that supports retries, job priorities and expiration.
Usage
Create a producer and enqueue jobs:
import { createProducer } from 'xque';
const producer = await createProducer({ redisConfig: { host: 'localhost', port: 6379, db: 0 });
const jobId = await producer.enqueue('myQueue', { message: 'hello' }, { expiry: 3600, priority: 1 });
const jobId2 = await producer.enqueue('myQueue', { message: 'world' }, { expiry: 7200, priority: 2 });
await producer.stop();Create a consumer and consume jobs from a queue:
import { createConsumer } from 'xque';
const consumer = await createConsumer({ redisConfig: { host: 'localhost', port: 6379, db: 0 }, queueName: 'myQueue' });
process.on('SIGTERM', () => {
consumer.stop();
});
await consumer.run(async (job) => {
console.log('Processing job', job);
});Semantic Versioning
Topscript is using Semantic Versioning: SemVer
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/mrkamel/xque-ts
License
The library is available as open source under the terms of the MIT License.
