Skip to content

Instantly share code, notes, and snippets.

@shortcircuit3
Created March 28, 2018 04:50
Show Gist options
  • Save shortcircuit3/ed60281585c742f82d8e81f7a5784413 to your computer and use it in GitHub Desktop.
Save shortcircuit3/ed60281585c742f82d8e81f7a5784413 to your computer and use it in GitHub Desktop.
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