Skip to content

Commit

Permalink
change task signature
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoobes committed Jul 18, 2024
1 parent c35337c commit d1680e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/core/structures/default-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 9 additions & 5 deletions src/types/core-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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>
}


0 comments on commit d1680e5

Please sign in to comment.