diff --git a/types/bull/index.d.ts b/types/bull/index.d.ts index 97844cfbbb..e689629f04 100644 --- a/types/bull/index.d.ts +++ b/types/bull/index.d.ts @@ -273,18 +273,30 @@ declare namespace Bull { * * The callback is called everytime a job is placed in the queue. * It is passed an instance of the job as first argument. + * The callback can also be defined as the string path to a module + * exporting the callback function. Using a path 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. * * 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(callback: (job: Job) => void): Promise; + process(callback: ((job: Job) => void) | string): Promise; /** * Defines a processing function for the jobs placed into a given Queue. * * The callback is called everytime a job is placed in the queue. * It is passed an instance of the job as first argument. + * The callback can also be defined as the string path to a module + * exporting the callback function. Using a path 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. * * 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. @@ -292,7 +304,7 @@ declare namespace Bull { * * @param concurrency Bull will then call you handler in parallel respecting this max number. */ - process(concurrency: number, callback: (job: Job) => void): Promise; + process(concurrency: number, callback: ((job: Job) => void) | string): Promise; /** * Defines a processing function for the jobs placed into a given Queue. @@ -314,6 +326,12 @@ declare namespace Bull { * * The callback is called everytime a job is placed in the queue. * It is passed an instance of the job as first argument. + * The callback can also be defined as the string path to a module + * exporting the callback function. Using a path 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. * * 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. @@ -322,7 +340,7 @@ declare namespace Bull { * @param name Bull will only call the handler if the job name matches */ // tslint:disable-next-line:unified-signatures - process(name: string, callback: (job: Job) => void): Promise; + process(name: string, callback: ((job: Job) => void) | string): Promise; /** * Defines a processing function for the jobs placed into a given Queue. @@ -345,6 +363,12 @@ declare namespace Bull { * * The callback is called everytime a job is placed in the queue. * It is passed an instance of the job as first argument. + * The callback can also be defined as the string path to a module + * exporting the callback function. Using a path 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. * * 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. @@ -353,7 +377,7 @@ declare namespace Bull { * @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, callback: (job: Job) => void): Promise; + process(name: string, concurrency: number, callback: ((job: Job) => void) | string): Promise; /** * Defines a processing function for the jobs placed into a given Queue.