Created
March 28, 2018 04:50
-
-
Save shortcircuit3/ed60281585c742f82d8e81f7a5784413 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Queue = require('bull'); | |
const sendQueue = new Queue('Server A'); | |
const count = 10000; | |
sendQueue.process((job, done) => { | |
for (let i = 0; i < count; i++) { | |
const number = Math.round(i * 100 / count); | |
job.progress(number); | |
} | |
done(null, 'World'); | |
}); | |
// An error occured. | |
sendQueue.on('error', (error) => { | |
console.log(error); | |
}); | |
// A job has started. You can use `jobPromise.cancel()`` to abort it. | |
sendQueue.on('active', (job, jobPromise) => { | |
console.log('active'); | |
}); | |
// A job's progress was updated! | |
sendQueue.on('progress', (job, progress) => { | |
console.log('prog', progress); | |
}); | |
// A job successfully completed with a `result`. | |
sendQueue.on('completed', (job, result) => { | |
console.log('res', result); | |
}); | |
sendQueue.add({ msg: 'Hello' }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment