@eggjs/schedule
Version:
schedule plugin for egg, support corn job.
32 lines (31 loc) • 940 B
TypeScript
import type { Agent } from 'egg';
import type { EggScheduleItem, EggScheduleJobInfo } from './types.js';
import type { BaseStrategy } from './strategy/base.js';
export declare class Schedule {
#private;
closed: boolean;
constructor(agent: Agent);
/**
* register a custom Schedule Strategy
* @param {String} type - strategy type
* @param {Strategy} clz - Strategy class
*/
use(type: string, clz: typeof BaseStrategy): void;
/**
* load all schedule jobs, then initialize and register speical strategy
*/
init(): Promise<void>;
registerSchedule(scheduleItem: EggScheduleItem): void;
unregisterSchedule(key: string): boolean;
/**
* job finish event handler
*
* @param {Object} info - { id, key, success, message, workerId }
*/
onJobFinish(info: EggScheduleJobInfo): void;
/**
* start schedule
*/
start(): void;
close(): void;
}