@akindutire/zil-queue
v1.0.31
Published
A simple queuing engine that works on principle of SJF, FIFO, and multi priority scheduling algorithms
Downloads
76
Readme
zil-queue
A simple queuing engine that works on principle of FIFO, SJF, and multi priority scheduling algorithms
Installation
Use the package manager npm to install it.
npm install @akindutire/zil-queue --save
Dependency
- mongoose
Usage
const Queue = require('zil-queue')
//start the queue engine
// ['high', 'video', 'share', 'default'] is the multi priority list, task on the high queue will get executed before the video queue
new Queue(['high','video', 'share', 'default'], {useSJF: true, showQueueList: false})
const job1 = await Queue.add( 'video',
async (a, b, c, basePath) => {
const pkg = await import(basePath+'/example/exampleJob.js')
await pkg.run(a, b, c)
},
[
1,
2,
3,
process.cwd()
],
{maxRetry: 0, timeout: 5000}
)
console.log(job1) //{id: 20, hash: def343dfhhehu3hh4, pos: 8}
//To remove a job from a queue
await Queue.remove('def343dfhhehu3hh4') //true or false
Contribution
Pull requests are welcome, for major change please open an issue to discuss the change.
License
MIT