@clairejs/server 3.28.4 → 3.28.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ export declare abstract class AbstractJobScheduler {
|
|
|
26
26
|
protected abstract cancelJob(id: string): Promise<void>;
|
|
27
27
|
protected abstract retryJob(job: AbstractJob, at: number): Promise<void>;
|
|
28
28
|
protected abstract cleanupJob(id: string): Promise<void>;
|
|
29
|
+
protected afterJobRun(job: AbstractJob): Promise<void>;
|
|
29
30
|
/**
|
|
30
31
|
* Remove the scheduled job and prevent if from running in the future
|
|
31
32
|
* @param id The job id returned from scheduleJobAt function
|
|
@@ -27,6 +27,11 @@ export class AbstractJobScheduler {
|
|
|
27
27
|
await this.registerJob({ ...payload, id: jobId });
|
|
28
28
|
return jobId;
|
|
29
29
|
}
|
|
30
|
+
async afterJobRun(job) {
|
|
31
|
+
if (job.at) {
|
|
32
|
+
await this.cleanupJob(job.id).catch((err) => this.logger.error(`Failed to cleanup one time job ${job.id}`, err));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
30
35
|
/**
|
|
31
36
|
* Remove the scheduled job and prevent if from running in the future
|
|
32
37
|
* @param id The job id returned from scheduleJobAt function
|
|
@@ -65,7 +70,7 @@ export class AbstractJobScheduler {
|
|
|
65
70
|
this.logger.debug(`Calling job handler for ${job.id}`);
|
|
66
71
|
await jobHandler.handlerFn(job);
|
|
67
72
|
this.logger.debug(`Job handler for ${job.id} completed`);
|
|
68
|
-
await this.
|
|
73
|
+
await this.afterJobRun(job);
|
|
69
74
|
//-- job run success, update
|
|
70
75
|
update.lastSuccessAt = Date.now();
|
|
71
76
|
//-- reset retry count if this is cron job
|