Add cron mechanism (#3318)

* Add cron to message queue interfaces

* Add command to launch cron job

* Add command to stop cron job

* Update clean inactive workspaces job

* Isolate cron mechanism

* Code review returns

* Remove useless object.assign

* Add MessageQueuCronJobData interface

* Rename cron job utils

* Fix typing
This commit is contained in:
martmull
2024-01-09 12:23:45 +01:00
committed by GitHub
parent ed06cc0310
commit 361446d79c
9 changed files with 119 additions and 11 deletions

View File

@ -34,6 +34,19 @@ export class MessageQueueService implements OnModuleDestroy {
return this.driver.add(this.queueName, jobName, data, options);
}
addCron<T extends MessageQueueJobData | undefined>(
jobName: string,
data: T,
pattern: string,
options?: QueueJobOptions,
): Promise<void> {
return this.driver.addCron(this.queueName, jobName, data, pattern, options);
}
removeCron(jobName: string, pattern: string): Promise<void> {
return this.driver.removeCron(this.queueName, jobName, pattern);
}
work<T extends MessageQueueJobData>(
handler: ({ data, id }: { data: T; id: string }) => Promise<void> | void,
) {