mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
change task signature
This commit is contained in:
@@ -53,12 +53,9 @@ export class TaskScheduler implements Disposable {
|
||||
}
|
||||
try {
|
||||
const onTick = async function(this: CronJob) {
|
||||
task.execute({
|
||||
deps,
|
||||
id: uuid,
|
||||
lastTimeExecution: this.lastExecution,
|
||||
nextTimeExecution: this.nextDate().toJSDate()
|
||||
})
|
||||
task.execute({ id: uuid,
|
||||
lastTimeExecution: this.lastExecution,
|
||||
nextTimeExecution: this.nextDate().toJSDate() }, { deps })
|
||||
}
|
||||
const job = CronJob.from({ cronTime: task.trigger, onTick, timeZone: task.timezone });
|
||||
job.start();
|
||||
|
||||
@@ -225,10 +225,7 @@ export interface SernSubCommandGroupData extends BaseApplicationCommandOptionsDa
|
||||
|
||||
|
||||
export interface ScheduledTaskContext {
|
||||
/**
|
||||
* An object of dependencies configured in `makeDependencies`
|
||||
*/
|
||||
deps: UnpackedDependencies,
|
||||
|
||||
/**
|
||||
* the uuid of the current task being run
|
||||
*/
|
||||
@@ -243,12 +240,19 @@ export interface ScheduledTaskContext {
|
||||
nextTimeExecution: Date | null;
|
||||
}
|
||||
|
||||
//name subject to change
|
||||
interface TaskAttrs {
|
||||
/**
|
||||
* An object of dependencies configured in `makeDependencies`
|
||||
*/
|
||||
deps: UnpackedDependencies
|
||||
}
|
||||
|
||||
export interface ScheduledTask {
|
||||
name?: string;
|
||||
trigger: string | Date;
|
||||
timezone?: string;
|
||||
execute(tasks: ScheduledTaskContext): Awaitable<void>
|
||||
execute(tasks: ScheduledTaskContext, sdt: TaskAttrs): Awaitable<void>
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user