bull
bull copied to clipboard
Job events
Apologies if covered, but I don't see job events fired on completion - only the queue fires events for job completion. Is this correct for Bull?
All the events emitted by the queues can be found here: https://github.com/OptimalBits/bull/blob/master/REFERENCE.md#events
Thanks @manast, these seem to only exist on the queue itself, not the job. While I appreciate the subscriber is traditionaly separate from the process adding the job, I have a scenario where jobs are very short lived and need to have events fire on the job i.e
let job = queue.add(params); job.on('complete', result => { ... });
There would be no performance penalty in just doing this:
queue.on('completed', (job, result) => {
// job.id can be used to map it to an exact added job
}
or if the jobs are processed in separated workers you will need to do this:
queue.on('global:completed', (jobId, result) => {
...
}
Not totally related, but if there was an job event for 'updated', we could use this for talking to the job.
Any progress on this?
Ideally looking for a set of events similar to the main Queue so we can have:
let queue = new Queue('player-queue');
...
let job = queue.add({name: 'dude'});
job.on('complete', result => { ... });
I need in one thread, for example in a controller, to send a task to a handler and in the same controller to wait for the request execution result. A more detailed rationale can be read here.
https://github.com/bee-queue/bee-queue/wiki/Origin