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 {
|
try {
|
||||||
const onTick = async function(this: CronJob) {
|
const onTick = async function(this: CronJob) {
|
||||||
task.execute({
|
task.execute({ id: uuid,
|
||||||
deps,
|
lastTimeExecution: this.lastExecution,
|
||||||
id: uuid,
|
nextTimeExecution: this.nextDate().toJSDate() }, { deps })
|
||||||
lastTimeExecution: this.lastExecution,
|
|
||||||
nextTimeExecution: this.nextDate().toJSDate()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
const job = CronJob.from({ cronTime: task.trigger, onTick, timeZone: task.timezone });
|
const job = CronJob.from({ cronTime: task.trigger, onTick, timeZone: task.timezone });
|
||||||
job.start();
|
job.start();
|
||||||
|
|||||||
@@ -225,10 +225,7 @@ export interface SernSubCommandGroupData extends BaseApplicationCommandOptionsDa
|
|||||||
|
|
||||||
|
|
||||||
export interface ScheduledTaskContext {
|
export interface ScheduledTaskContext {
|
||||||
/**
|
|
||||||
* An object of dependencies configured in `makeDependencies`
|
|
||||||
*/
|
|
||||||
deps: UnpackedDependencies,
|
|
||||||
/**
|
/**
|
||||||
* the uuid of the current task being run
|
* the uuid of the current task being run
|
||||||
*/
|
*/
|
||||||
@@ -243,12 +240,19 @@ export interface ScheduledTaskContext {
|
|||||||
nextTimeExecution: Date | null;
|
nextTimeExecution: Date | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//name subject to change
|
||||||
|
interface TaskAttrs {
|
||||||
|
/**
|
||||||
|
* An object of dependencies configured in `makeDependencies`
|
||||||
|
*/
|
||||||
|
deps: UnpackedDependencies
|
||||||
|
}
|
||||||
|
|
||||||
export interface ScheduledTask {
|
export interface ScheduledTask {
|
||||||
name?: string;
|
name?: string;
|
||||||
trigger: string | Date;
|
trigger: string | Date;
|
||||||
timezone?: string;
|
timezone?: string;
|
||||||
execute(tasks: ScheduledTaskContext): Awaitable<void>
|
execute(tasks: ScheduledTaskContext, sdt: TaskAttrs): Awaitable<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user