@clairejs/server 3.20.1 → 3.20.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,7 +1,8 @@
1
1
  ## Change Log
2
2
 
3
- #### 3.20.1:
3
+ #### 3.20.2:
4
4
 
5
+ - fix redlock timeout issue
5
6
  - fix req not resolve leads to undefined request in DefaultHttpRequestHandler
6
7
  - fix concurrent transactions in updateRecords
7
8
  - update claire core, claire orm and fix returning
@@ -29,7 +29,7 @@ export declare class LocalJobScheduler extends AbstractJobScheduler implements I
29
29
  /**
30
30
  * The time to lock active scheduler
31
31
  */
32
- protected readonly keyRetentionDurationSecond: number;
32
+ protected readonly keyRetentionDurationSeconds: number;
33
33
  protected intervals: any[];
34
34
  private mutexHoldInterval?;
35
35
  private isActive;
@@ -55,7 +55,7 @@ export declare class LocalJobScheduler extends AbstractJobScheduler implements I
55
55
  /**
56
56
  * The time to lock active scheduler
57
57
  */
58
- keyRetentionDurationSecond?: number);
58
+ keyRetentionDurationSeconds?: number);
59
59
  private sendJob;
60
60
  private processMessage;
61
61
  private extendMutexKey;
@@ -32,7 +32,7 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
32
32
  holdMutexKey;
33
33
  uniqueIdKey;
34
34
  multiClientChannel;
35
- keyRetentionDurationSecond;
35
+ keyRetentionDurationSeconds;
36
36
  intervals = [];
37
37
  mutexHoldInterval;
38
38
  isActive = false;
@@ -58,7 +58,7 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
58
58
  /**
59
59
  * The time to lock active scheduler
60
60
  */
61
- keyRetentionDurationSecond = 30) {
61
+ keyRetentionDurationSeconds = 30) {
62
62
  super(logger, db);
63
63
  this.logger = logger;
64
64
  this.db = db;
@@ -69,7 +69,7 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
69
69
  this.holdMutexKey = holdMutexKey;
70
70
  this.uniqueIdKey = uniqueIdKey;
71
71
  this.multiClientChannel = multiClientChannel;
72
- this.keyRetentionDurationSecond = keyRetentionDurationSecond;
72
+ this.keyRetentionDurationSeconds = keyRetentionDurationSeconds;
73
73
  }
74
74
  sendJob(type, messageId, data) {
75
75
  this.subscribeClient.publish(this.multiClientChannel, JSON.stringify({ type, messageId, data }));
@@ -116,7 +116,7 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
116
116
  if (!this.redisClient) {
117
117
  return;
118
118
  }
119
- await this.redisClient.setex(this.holdMutexKey, this.keyRetentionDurationSecond, 1);
119
+ await this.redisClient.setex(this.holdMutexKey, this.keyRetentionDurationSeconds, 1);
120
120
  this.logger.debug("Scheduler extends mutex key");
121
121
  }
122
122
  async afterJob({ at, ...job }, tx) {
@@ -139,15 +139,15 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
139
139
  //-- try to claim active scheduler
140
140
  const locker = new Redlock([this.redisClient]);
141
141
  try {
142
- const lock = await locker.acquire([this.lockMutexKey], this.keyRetentionDurationSecond);
142
+ const lock = await locker.acquire([this.lockMutexKey], this.keyRetentionDurationSeconds * 1000);
143
143
  this.isActive = true;
144
144
  await this.extendMutexKey();
145
145
  await lock.release();
146
- this.logger.debug("Being active scheduler");
146
+ this.logger.debug("Became active scheduler");
147
147
  //-- actively hold the mutex key
148
148
  this.mutexHoldInterval = setInterval(() => {
149
149
  this.extendMutexKey();
150
- }, Math.trunc((this.keyRetentionDurationSecond * 1000) / 2) + 1);
150
+ }, Math.trunc((this.keyRetentionDurationSeconds * 1000) / 2) + 1);
151
151
  }
152
152
  catch (err) {
153
153
  this.logger.info("Failed to lock mutex key, ignore", err);
@@ -35,10 +35,10 @@ let ClaireServer = class ClaireServer extends ClaireApp {
35
35
  }
36
36
  //-- save mounted endpoint info in server store to prevent circular dependency when resolving http request handler in controller
37
37
  for (const endpoint of mountedEndpointInfo) {
38
- this.logger.info(`Mounting: ${endpoint.method}:${endpoint.mount}`);
38
+ this.logger.debug(`Mounting: ${endpoint.method}:${endpoint.mount}`);
39
39
  }
40
40
  getGlobalStore().mountedEndpointInfo = mountedEndpointInfo;
41
- this.logger.debug("Claire server initing");
41
+ this.logger.info("Claire server initing");
42
42
  //-- handle exceptions
43
43
  this.logger.debug(`Setting up exception handlers`);
44
44
  process.on("SIGTERM", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/server",
3
- "version": "3.20.1",
3
+ "version": "3.20.2",
4
4
  "description": "Claire server NodeJs framework written in Typescript.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",