@@ -29,23 +29,26 @@ export class Job<DATA = unknown | void> {
29
29
args : Partial < IJobParameters < void > > & {
30
30
name : string ;
31
31
type : 'normal' | 'single' ;
32
- }
32
+ } ,
33
+ byJobProcessor ?
33
34
) ;
34
35
constructor (
35
36
agenda : Agenda ,
36
37
args : Partial < IJobParameters < DATA > > & {
37
38
name : string ;
38
39
type : 'normal' | 'single' ;
39
40
data : DATA ;
40
- }
41
+ } ,
42
+ byJobProcessor ?
41
43
) ;
42
44
constructor (
43
45
readonly agenda : Agenda ,
44
46
args : Partial < IJobParameters < DATA > > & {
45
47
name : string ;
46
48
type : 'normal' | 'single' ;
47
49
data : DATA ;
48
- }
50
+ } ,
51
+ private readonly byJobProcessor = false
49
52
) {
50
53
// Set attrs to args
51
54
this . attrs = {
@@ -161,8 +164,7 @@ export class Job<DATA = unknown | void> {
161
164
}
162
165
163
166
async isRunning ( ) : Promise < boolean > {
164
- const definition = this . agenda . definitions [ this . attrs . name ] ;
165
- if ( ! definition || ! this . agenda . isActiveJobProcessor ( ) ) {
167
+ if ( ! this . byJobProcessor ) {
166
168
// we have no job definition, therfore we are not the job processor, but a client call
167
169
// so we get the real state from database
168
170
await this . fetchStatus ( ) ;
@@ -197,13 +199,14 @@ export class Job<DATA = unknown | void> {
197
199
}
198
200
199
201
async isDead ( ) : Promise < boolean > {
200
- const definition = this . agenda . definitions [ this . attrs . name ] ;
201
- if ( ! definition || ! this . agenda . isActiveJobProcessor ( ) ) {
202
+ if ( ! this . byJobProcessor ) {
202
203
// we have no job definition, therfore we are not the job processor, but a client call
203
204
// so we get the real state from database
204
205
await this . fetchStatus ( ) ;
205
206
}
206
207
208
+ const definition = this . agenda . definitions [ this . attrs . name ] ;
209
+
207
210
const lockDeadline = new Date ( Date . now ( ) - definition . lockLifetime ) ;
208
211
209
212
// This means a job has "expired", as in it has not been "touched" within the lockoutTime
0 commit comments