@clairejs/server 3.26.1 → 3.26.2

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
@@ -1,5 +1,9 @@
1
1
  ## Change Log
2
2
 
3
+ #### 3.26.2
4
+
5
+ - clean up jobs after run
6
+
3
7
  #### 3.26.1
4
8
 
5
9
  - remove the resolve url function in file upload handler
@@ -29,6 +29,11 @@ export declare abstract class AbstractJobScheduler {
29
29
  * @param id The job id returned from scheduleJobAt function
30
30
  */
31
31
  protected abstract cancelJob(id: string): Promise<void>;
32
+ /**
33
+ * Clean up the job after it has been executed
34
+ * @param job The job to clean up
35
+ */
36
+ protected abstract cleanupJob(job: AbstractJob): Promise<void>;
32
37
  /**
33
38
  * Remove the scheduled job and prevent if from running in the future
34
39
  * @param id The job id returned from scheduleJobAt function
@@ -129,6 +129,8 @@ export class AbstractJobScheduler {
129
129
  await jobHandler.handlerFn(job);
130
130
  //-- job run success, update
131
131
  update.lastSuccessAt = Date.now();
132
+ //-- clean up
133
+ await this.cleanupJob(job);
132
134
  //-- reset retry count if this is cron job
133
135
  if (job.cron) {
134
136
  if (job.retryCount) {
@@ -19,6 +19,7 @@ export declare class AwsJobScheduler extends AbstractJobScheduler {
19
19
  constructor(logger: AbstractLogger, db: AbstractDbAdapter, jobRepo: AbstractJobRepository, apiLambdaFunctionArn: string, jobNamespace: string, eventBusName?: string);
20
20
  handleCron(jobInfo: AbstractJob): Promise<void>;
21
21
  private generateCronFromTimestamp;
22
+ protected cleanupJob(job: AbstractJob): Promise<void>;
22
23
  protected getScheduledJobs(): Promise<AbstractJob[]>;
23
24
  protected _scheduleJob(jobInfo: AbstractJob): Promise<void>;
24
25
  cancelJob(jobId: string): Promise<void>;
@@ -49,6 +49,14 @@ let AwsJobScheduler = class AwsJobScheduler extends AbstractJobScheduler {
49
49
  date.getUTCFullYear(),
50
50
  ].join(" ");
51
51
  }
52
+ async cleanupJob(job) {
53
+ if (job.cron) {
54
+ //-- do nothing
55
+ }
56
+ else {
57
+ await this.cancelJob(job.id);
58
+ }
59
+ }
52
60
  async getScheduledJobs() {
53
61
  const allRules = await this.eventbridge
54
62
  .listRules({
@@ -50,6 +50,7 @@ export declare class LocalJobScheduler extends AbstractJobScheduler implements I
50
50
  private sendJob;
51
51
  private processMessage;
52
52
  private extendMutexKey;
53
+ protected cleanupJob(): Promise<void>;
53
54
  init(): Promise<void>;
54
55
  exit(): void;
55
56
  protected getScheduledJobs(): Promise<AbstractJob[]>;
@@ -103,6 +103,9 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
103
103
  await this.redisClient.setex(this.holdMutexKey, this.keyRetentionDurationSeconds, 1);
104
104
  this.logger.debug("Scheduler extends mutex key");
105
105
  }
106
+ async cleanupJob() {
107
+ //-- do nothing
108
+ }
106
109
  async init() {
107
110
  this.logger.debug("LocalJobScheduler init");
108
111
  //-- subscribe to multi client channel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.26.1",
3
+ "version": "3.26.2",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",