| 133 | * Represents a scheduled task that can be managed and executed. |
| 134 | */ |
| 135 | export interface ScheduledTask { |
| 136 | id: string, |
| 137 | name?: string, |
| 138 | |
| 139 | start(): void | Promise<void>; |
| 140 | stop(): void | Promise<void>; |
| 141 | getStatus(): string; |
| 142 | destroy(): void | Promise<void>; |
| 143 | execute(): Promise<any>; |
| 144 | getNextRun(): Date | null; |
| 145 | |
| 146 | /** The next `count` instants this task's expression matches, from now. */ |
| 147 | getNextRuns(count: number): Date[]; |
| 148 | /** Whether the given date matches this task's expression. */ |
| 149 | match(date: Date): boolean; |
| 150 | /** Milliseconds until the next run, or `null` when the task is stopped. */ |
| 151 | msToNext(): number | null; |
| 152 | /** Whether an execution is currently in progress. */ |
| 153 | isBusy(): boolean; |
| 154 | /** Remaining executions when `maxExecutions` is set, otherwise `undefined`. */ |
| 155 | runsLeft(): number | undefined; |
| 156 | /** The original cron expression. */ |
| 157 | getPattern(): string; |
| 158 | /** |
| 159 | * Information about the last actual execution, or `null` if the task has not |
| 160 | * run yet. `date` reflects when the execution really ran, not when a tick was |
| 161 | * checked. |
| 162 | */ |
| 163 | lastRun(): LastRun | null; |
| 164 | |
| 165 | on(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void |
| 166 | off(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void |
| 167 | once(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void |
| 168 | } |
no outgoing calls
no test coverage detected