change task signature

This commit is contained in:
Jacob Nguyen
2024-07-18 16:47:07 -05:00
parent c35337c3cf
commit d1680e51fc
2 changed files with 12 additions and 11 deletions

View File

@@ -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();

View File

@@ -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>
} }