@clairejs/server 3.22.12 → 3.22.13
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
|
@@ -33,17 +33,25 @@ export class AbstractJobScheduler {
|
|
|
33
33
|
*/
|
|
34
34
|
async executeJob(job) {
|
|
35
35
|
//-- run job
|
|
36
|
+
console.log("executeJob", job);
|
|
36
37
|
const allJobs = await this.getAvailableJobInfo();
|
|
38
|
+
console.log("alljobs", allJobs);
|
|
37
39
|
const jobHandler = allJobs.find((j) => j.jobName === job.jobName);
|
|
40
|
+
console.log("creating transaction");
|
|
38
41
|
const tx = await this.db.createTransaction();
|
|
42
|
+
console.log("transaction created");
|
|
39
43
|
try {
|
|
40
44
|
if (!jobHandler) {
|
|
45
|
+
console.log("removing job");
|
|
41
46
|
//-- remove job
|
|
42
47
|
this.logger.info(`Remove job with id: ${job.id} as handler is not found`);
|
|
43
48
|
await this.removeJob(job.id, tx);
|
|
49
|
+
console.log("job removed");
|
|
44
50
|
}
|
|
45
51
|
else {
|
|
52
|
+
console.log("handle job");
|
|
46
53
|
const newJob = await jobHandler.handlerFn({ ...job }, tx);
|
|
54
|
+
console.log("return new job", newJob);
|
|
47
55
|
if (job.at) {
|
|
48
56
|
if (!newJob) {
|
|
49
57
|
await this.removeJob(job.id, tx);
|
|
@@ -53,9 +61,11 @@ export class AbstractJobScheduler {
|
|
|
53
61
|
await this.afterJob(newJob, tx);
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
|
-
this.logger.debug("Job tx commiting");
|
|
57
64
|
}
|
|
65
|
+
console.log("commiting job");
|
|
66
|
+
this.logger.debug("Job tx commiting");
|
|
58
67
|
await tx.commit();
|
|
68
|
+
console.log("job commiited");
|
|
59
69
|
this.logger.debug("Job tx committed");
|
|
60
70
|
}
|
|
61
71
|
catch (err) {
|
|
@@ -34,8 +34,10 @@ let AwsJobScheduler = class AwsJobScheduler extends AbstractJobScheduler {
|
|
|
34
34
|
this.eventBusName = eventBusName;
|
|
35
35
|
}
|
|
36
36
|
async handleCron(jobInfo) {
|
|
37
|
+
console.log("handleCron in AwsJobScheduler", jobInfo);
|
|
37
38
|
this.logger.debug(`Handle cron`, jobInfo);
|
|
38
39
|
await this.executeJob(jobInfo);
|
|
40
|
+
console.log("after execute job");
|
|
39
41
|
}
|
|
40
42
|
async afterJob(_job, _tx) {
|
|
41
43
|
//-- do nothing
|
|
@@ -108,7 +108,9 @@ export class LambdaWrapper {
|
|
|
108
108
|
return toApiGatewayFormat({ code: 200, headers: corsHeaders, cookies: {} });
|
|
109
109
|
}
|
|
110
110
|
if (requestOptions.method === CRON_REQUEST_METHOD) {
|
|
111
|
+
console.log("handling cron");
|
|
111
112
|
await this.jobScheduler?.handleCron(requestOptions.body);
|
|
113
|
+
console.log("handling cron done");
|
|
112
114
|
return toApiGatewayFormat({ code: 200, headers: corsHeaders, cookies: {} });
|
|
113
115
|
}
|
|
114
116
|
if (Object.values(HttpMethod).includes(requestOptions.method)) {
|