From 1db75c0e2e6ef70a88835f6844d29795defc7b70 Mon Sep 17 00:00:00 2001 From: Doug Ayers <4142577+douglascayers@users.noreply.github.com> Date: Tue, 22 Oct 2019 15:33:39 -0500 Subject: [PATCH] [@types/bull] Update Queue and Job definitions (#39244) * add argument for queue.close(boolean) * fixes #38619 add `notFetch` parameter * revert formatting * reapply changes w/o formatting * undo formatting (again) * look, I finally saved without formatting :) * revert formatting * save without formatting --- types/bull/bull-tests.tsx | 8 ++++++++ types/bull/index.d.ts | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/types/bull/bull-tests.tsx b/types/bull/bull-tests.tsx index 22cd0dc638..916e8fe69a 100644 --- a/types/bull/bull-tests.tsx +++ b/types/bull/bull-tests.tsx @@ -209,6 +209,7 @@ myQueue.on('active', (job: Queue.Job) => { const nextJobId: Queue.JobId = val[1]; } }); + job.moveToCompleted('done', true, false); job.moveToFailed({ message: "Call to external service failed!" }, true); job.moveToFailed(new Error('test error'), true); @@ -222,6 +223,13 @@ myQueue.on('active', (job: Queue.Job) => { job.discard(); }); +// Close queues + +myQueue.close(); + +const doNotWaitForJobs = true; +myQueue.close(doNotWaitForJobs); + // Get Redis clients const clients = myQueue.clients; diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index 434378acea..8032b01ddf 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -258,7 +258,7 @@ declare namespace Bull { * Moves a job to the `completed` queue. Pulls a job from 'waiting' to 'active' * and returns a tuple containing the next jobs data and id. If no job is in the `waiting` queue, returns null. */ - moveToCompleted(returnValue?: string, ignoreLock?: boolean): Promise<[any, JobId] | null>; + moveToCompleted(returnValue?: string, ignoreLock?: boolean, notFetch?: boolean): Promise<[any, JobId] | null>; /** * Moves a job to the `failed` queue. Pulls a job from 'waiting' to 'active' @@ -611,7 +611,7 @@ declare namespace Bull { * `close` can be called from anywhere, with one caveat: * if called from within a job handler the queue won't close until after the job has been processed */ - close(): Promise; + close(doNotWaitJobs?: boolean): Promise; /** * Returns a promise that will return the job instance associated with the jobId parameter.