From 2cd2bd872694741753a201574a8168a4a913cdb2 Mon Sep 17 00:00:00 2001 From: Alex Regan Date: Tue, 20 Feb 2018 15:09:07 -0700 Subject: [PATCH] fix(bull): adds `Queue.process` overloads --- types/bull/index.d.ts | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index a7a9ea350b..a77552cb9a 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -265,6 +265,24 @@ declare namespace Bull { */ process(callback: (job: Job, done: DoneCallback) => void): void; + /** + * Defines a processing function for the jobs placed into a given Queue. + * + * The handlerPath defines the path to the job callback. + * Using a handlerPath has several advantages: + * - The process is sandboxed so if it crashes it does not affect the worker. + * - You can run blocking code without affecting the queue (jobs will not stall). + * - Much better utilization of multi-core CPUs. + * - Less connections to redis. + * + * It is passed an instance of the job as first argument. + * + * A promise must be returned to signal job completion. + * If the promise is rejected, the error will be passed as a second argument to the "failed" event. + * If it is resolved, its value will be the "completed" event's second argument. + */ + process(handlerPath: string): void; + /** * Defines a processing function for the jobs placed into a given Queue. * @@ -291,6 +309,26 @@ declare namespace Bull { */ process(concurrency: number, callback: (job: Job) => void): Promise; + /** + * Defines a processing function for the jobs placed into a given Queue. + * + * The handlerPath defines the path to the job callback. + * Using a handlerPath has several advantages: + * - The process is sandboxed so if it crashes it does not affect the worker. + * - You can run blocking code without affecting the queue (jobs will not stall). + * - Much better utilization of multi-core CPUs. + * - Less connections to redis. + * + * It is passed an instance of the job as first argument. + * + * A promise must be returned to signal job completion. + * If the promise is rejected, the error will be passed as a second argument to the "failed" event. + * If it is resolved, its value will be the "completed" event's second argument. + * + * @param concurrency Bull will then call you handler in parallel respecting this max number. + */ + process(concurrency: number, handlerPath: string): void; + /** * Defines a processing function for the jobs placed into a given Queue. * @@ -337,6 +375,27 @@ declare namespace Bull { // tslint:disable-next-line:unified-signatures process(name: string, callback: (job: Job, done: DoneCallback) => void): void; + /** + * Defines a processing function for the jobs placed into a given Queue. + * + * The handlerPath defines the path to the job callback. + * Using a handlerPath has several advantages: + * - The process is sandboxed so if it crashes it does not affect the worker. + * - You can run blocking code without affecting the queue (jobs will not stall). + * - Much better utilization of multi-core CPUs. + * - Less connections to redis. + * + * It is passed an instance of the job as first argument. + * + * A promise must be returned to signal job completion. + * If the promise is rejected, the error will be passed as a second argument to the "failed" event. + * If it is resolved, its value will be the "completed" event's second argument. + * + * @param name Bull will only call the handler if the job name matches + * @param concurrency Bull will then call you handler in parallel respecting this max number. + */ + process(name: string, concurrency: number, handlerPath: string): void; + /** * Defines a named processing function for the jobs placed into a given Queue. *