@@ -21,7 +21,7 @@ export class Worker<P extends object> {
21
21
public readonly concurrency : number ;
22
22
23
23
private executionCount : number ;
24
- private executer : ( payload : P ) => CancellablePromise < any > ;
24
+ private executer : ( payload : P , id : string ) => CancellablePromise < any > ;
25
25
26
26
private onStart : ( job : Job < P > ) => void ;
27
27
private onSuccess : ( job : Job < P > ) => void ;
@@ -35,7 +35,7 @@ export class Worker<P extends object> {
35
35
* @param executer function to run jobs
36
36
* @param options to configure worker
37
37
*/
38
- constructor ( name : string , executer : ( payload : P ) => Promise < any > , options : WorkerOptions < P > = { } ) {
38
+ constructor ( name : string , executer : ( payload : P , id : string ) => Promise < any > , options : WorkerOptions < P > = { } ) {
39
39
const {
40
40
onStart = ( job : Job < P > ) => { } ,
41
41
onSuccess = ( job : Job < P > ) => { } ,
@@ -81,7 +81,7 @@ export class Worker<P extends object> {
81
81
if ( timeout > 0 ) {
82
82
return this . executeWithTimeout ( job , timeout ) ;
83
83
} else {
84
- return this . executer ( payload ) ;
84
+ return this . executer ( payload , job . id ) ;
85
85
}
86
86
}
87
87
private executeWithTimeout ( job : Job < P > , timeout : number ) {
@@ -92,7 +92,7 @@ export class Worker<P extends object> {
92
92
reject ( new Error ( `Job ${ job . id } timed out` ) ) ;
93
93
} , timeout ) ;
94
94
} ) ;
95
- const executerPromise = this . executer ( job . payload ) ;
95
+ const executerPromise = this . executer ( job . payload , job . id ) ;
96
96
if ( executerPromise ) {
97
97
cancel = executerPromise [ CANCEL ] ;
98
98
try {
0 commit comments