@@ -15,6 +15,16 @@ import { calculateProcessEvery } from './utils/processEvery';
15
15
16
16
const log = debug ( 'agenda' ) ;
17
17
18
+ const DefaultOptions = {
19
+ processEvery : 5000 ,
20
+ defaultConcurrency : 5 ,
21
+ maxConcurrency : 20 ,
22
+ defaultLockLimit : 0 ,
23
+ lockLimit : 0 ,
24
+ defaultLockLifetime : 10 * 60 * 1000 ,
25
+ sort : { nextRunAt : 1 , priority : - 1 }
26
+ } ;
27
+
18
28
/**
19
29
* @class
20
30
*/
@@ -73,20 +83,20 @@ export class Agenda extends EventEmitter {
73
83
defaultLockLifetime ?: number ;
74
84
// eslint-disable-next-line @typescript-eslint/ban-types
75
85
} & ( IDatabaseOptions | IMongoOptions | { } ) &
76
- IDbConfig = { } ,
86
+ IDbConfig = DefaultOptions ,
77
87
cb ?: ( error ?: Error ) => void
78
88
) {
79
89
super ( ) ;
80
90
81
91
this . attrs = {
82
92
name : config . name || '' ,
83
- processEvery : calculateProcessEvery ( config . processEvery ) ,
84
- defaultConcurrency : config . defaultConcurrency || 5 ,
85
- maxConcurrency : config . maxConcurrency || 20 ,
86
- defaultLockLimit : config . defaultLockLimit || 0 ,
87
- lockLimit : config . lockLimit || 0 ,
88
- defaultLockLifetime : config . defaultLockLifetime || 10 * 60 * 1000 , // 10 minute default lockLifetime
89
- sort : config . sort || { nextRunAt : 1 , priority : - 1 }
93
+ processEvery : calculateProcessEvery ( config . processEvery ) || DefaultOptions . processEvery ,
94
+ defaultConcurrency : config . defaultConcurrency || DefaultOptions . defaultConcurrency ,
95
+ maxConcurrency : config . maxConcurrency || DefaultOptions . maxConcurrency ,
96
+ defaultLockLimit : config . defaultLockLimit || DefaultOptions . defaultLockLimit ,
97
+ lockLimit : config . lockLimit || DefaultOptions . lockLimit ,
98
+ defaultLockLifetime : config . defaultLockLifetime || DefaultOptions . defaultLockLifetime , // 10 minute default lockLifetime
99
+ sort : config . sort || DefaultOptions . sort
90
100
} ;
91
101
92
102
this . ready = new Promise ( resolve => this . once ( 'ready' , resolve ) ) ;
0 commit comments