mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-02 00:00:04 +00:00
Add finished function to Job
This commit is contained in:
@@ -98,3 +98,18 @@ videoQueue.process( ( job: VideoJob ) => { // don't forget to remove the done ca
|
||||
// If the job throws an unhandled exception it is also handled correctly
|
||||
throw new Error( 'some unexpected error' );
|
||||
} );
|
||||
|
||||
|
||||
var addVideo1Job = videoQueue.add( { video: 'http://example.com/video1.mov' } );
|
||||
|
||||
addVideo1Job.then((video1Job) => {
|
||||
// When job has successfully be placed in the queue the job is returned
|
||||
// then wait for completion
|
||||
return video1Job.finished();
|
||||
})
|
||||
.then(() => {
|
||||
// video1Job completed successfully
|
||||
})
|
||||
.catch((err) => {
|
||||
// error
|
||||
});
|
||||
|
||||
7
bull/index.d.ts
vendored
7
bull/index.d.ts
vendored
@@ -47,6 +47,13 @@ declare module "bull" {
|
||||
* @returns {Promise} A promise that resolves when the job is scheduled for retry.
|
||||
*/
|
||||
retry(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns a promise the resolves when the job has been finished.
|
||||
* TODO: Add a watchdog to check if the job has finished periodically.
|
||||
* since pubsub does not give any guarantees.
|
||||
*/
|
||||
finished(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Backoff {
|
||||
|
||||
Reference in New Issue
Block a user