-
Notifications
You must be signed in to change notification settings - Fork 568
/
interface.ts
30 lines (23 loc) 路 992 Bytes
/
interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { IMidwayApplication, IMidwayContext, NextFunction as BaseNextFunction } from '@midwayjs/core';
import { CronJob, CronJobParameters } from 'cron';
export { CronJob } from 'cron';
export type CronJobOptions = Omit<CronJobParameters, 'onTick'|'onComplete'>;
export interface CronOptions {
defaultCronJobOptions?: CronJobOptions;
}
export interface IJob {
/**
* The function to fire at the specified time. If an onComplete callback was provided, onTick will receive it as an argument. onTick may call onComplete when it has finished its work.
*/
onTick();
/**
* A function that will fire when the job is stopped with job.stop(), and may also be called by onTick at the end of each run.
*/
onComplete?(result: any);
}
export type JobNameOrClz = string | (new (...args) => IJob);
export interface Application extends IMidwayApplication<Context> {}
export type NextFunction = BaseNextFunction;
export interface Context extends IMidwayContext {
job: CronJob;
}