From 589188a626dd89b4e96a2cd6862607d1ef8bddd7 Mon Sep 17 00:00:00 2001 From: Alec Brunelle Date: Thu, 2 Aug 2018 11:12:33 -0400 Subject: [PATCH 1/2] Add types to private functions - Job.moveToCompleted - Job.moveToFailed - Queue.getNextJob - Also add null possibility to Queue.getJob --- types/bull/index.d.ts | 1 + types/bull/v2/index.d.ts | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index a11ae0257a..ac820290f2 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -9,6 +9,7 @@ // David Koblas // Bond Akinmade // Wuha Team +// Alec Brunelle // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 diff --git a/types/bull/v2/index.d.ts b/types/bull/v2/index.d.ts index 3c89655101..e97920efd7 100644 --- a/types/bull/v2/index.d.ts +++ b/types/bull/v2/index.d.ts @@ -54,6 +54,22 @@ declare module "bull" { * since pubsub does not give any guarantees. */ finished(): Promise; + + /** + * Moves a job to the completed queue and moves a new job from 'waiting' to 'active'. + * @param returnValue The jobs success message. + * @param ignoreLock True when wanting to ignore the redis lock on this job. + * @returns Returns the id of the pulled job. + */ + moveToCompleted(returnValue: string, ignoreLock: boolean): Promise; + + /** + * Moves a job to the failed queue. + * @param errorInfo The jobs error message. + * @param ignoreLock True when wanting to ignore the redis lock on this job. + * @returns void + */ + moveToFailed(errorInfo: ErrorMessage, ignoreLock: boolean): Promise; } export interface Backoff { @@ -204,7 +220,7 @@ declare module "bull" { * Returns a promise that will return the job instance associated with the jobId parameter. * If the specified job cannot be located, the promise callback parameter will be set to null. */ - getJob(jobId: string): Promise; + getJob(jobId: string): Promise; /** * Tells the queue remove all jobs created outside of a grace period in milliseconds. @@ -217,6 +233,18 @@ declare module "bull" { * 'ready', 'error', 'activ', 'progress', 'completed', 'failed', 'paused', 'resumed', 'cleaned' */ on(eventName: string, callback: EventCallback): void; + + /** + * Moves the next job from 'waiting' to 'active'. + * Sets the processedOn timestamp to the current datetime. + * @param jobId If specified, will move a specific job from 'waiting' to 'active', + * @returns Returns the job moved from waiting to active queue. + */ + getNextJob:(jobId?: string) => Promise; + } + + interface ErrorMessage { + message: string; } interface EventCallback { From d157a0af255c324df08e4a3c171a60e74727c23c Mon Sep 17 00:00:00 2001 From: Alec Brunelle Date: Mon, 20 Aug 2018 16:05:48 -0400 Subject: [PATCH 2/2] changes based on other pr being merged --- types/bull/v2/index.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/types/bull/v2/index.d.ts b/types/bull/v2/index.d.ts index e97920efd7..4ea3f82df7 100644 --- a/types/bull/v2/index.d.ts +++ b/types/bull/v2/index.d.ts @@ -56,12 +56,14 @@ declare module "bull" { finished(): Promise; /** - * Moves a job to the completed queue and moves a new job from 'waiting' to 'active'. + * 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. * @param returnValue The jobs success message. * @param ignoreLock True when wanting to ignore the redis lock on this job. - * @returns Returns the id of the pulled job. + * @returns Contains the next jobs data and id or null if job left in 'waiting' queue. */ - moveToCompleted(returnValue: string, ignoreLock: boolean): Promise; + moveToCompleted(returnValue: string, ignoreLock: boolean): Promise; /** * Moves a job to the failed queue.