| 75 | onSkipped: OnSkippedFn; |
| 76 | |
| 77 | constructor(timeMatcher: TimeMatcher, onMatch: OnMatch, options?: RunnerOptions){ |
| 78 | this.timeMatcher = timeMatcher; |
| 79 | this.onMatch = onMatch; |
| 80 | this.noOverlap = options == undefined || options.noOverlap === undefined ? false : options.noOverlap; |
| 81 | this.maxExecutions = options?.maxExecutions; |
| 82 | this.maxRandomDelay = options?.maxRandomDelay || 0; |
| 83 | this.missedExecutionTolerance = options?.missedExecutionTolerance ?? DEFAULT_MISSED_EXECUTION_TOLERANCE; |
| 84 | this.logger = options?.logger || logger; |
| 85 | |
| 86 | this.onMissedExecution = options?.onMissedExecution || emptyOnFn; |
| 87 | this.onOverlap = options?.onOverlap || emptyOnFn; |
| 88 | |
| 89 | this.onError = options?.onError || ((date: Date, error: Error) => this.logger.error('Task failed with error!', error)); |
| 90 | this.onFinished = options?.onFinished || emptyHookFn; |
| 91 | this.beforeRun = options?.beforeRun || emptyHookFn; |
| 92 | |
| 93 | this.onMaxExecutions = options?.onMaxExecutions || emptyOnFn; |
| 94 | |
| 95 | this.runCoordinator = options?.runCoordinator; |
| 96 | this.coordinatorKeyPrefix = options?.coordinatorKeyPrefix || ''; |
| 97 | this.coordinatorTtl = options?.coordinatorTtl ?? DEFAULT_COORDINATOR_TTL; |
| 98 | this.onSkipped = options?.onSkipped || emptySkipFn; |
| 99 | |
| 100 | this.runCount = 0; |
| 101 | this.running = false; |
| 102 | } |
| 103 | |
| 104 | private onErrorFallback = (date: Date, error: Error) => { |
| 105 | this.logger.error('Task failed with error!', error); |