@ikonintegration/ikapi 3.1.26 → 3.1.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikonintegration/ikapi",
3
- "version": "3.1.26",
3
+ "version": "3.1.29",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "main.js",
@@ -17,7 +17,7 @@
17
17
  "@aws-sdk/credential-provider-node": "^3.137.0",
18
18
  "@aws-sdk/node-http-handler": "^3.127.0",
19
19
  "@aws-sdk/util-dynamodb": "^3.137.0",
20
- "@ikonintegration/mod-resources-tracker-client": "0.0.16",
20
+ "@ikonintegration/mod-resources-tracker-client": "0.0.17",
21
21
  "abind": "^1.0.5",
22
22
  "bluebird": "^3.7.2",
23
23
  "email-templates": "^8.0.8",
@@ -28,14 +28,16 @@ export default class IKProcess {
28
28
  //Main interface
29
29
  async execute(executionFunc) {
30
30
  this.logger.debug("Starting main process code");
31
+ //Tracker
32
+ if (this.allowExecutionIdentification && this.tracker) this.tracker.resetExecutionTrace();
31
33
  //Connect DB
32
34
  if (this.db) await this.db.connect();
33
- //program loop
35
+ //Program loop
34
36
  setInterval( async () => {
35
37
  await this._execute(executionFunc);
36
38
  }, this.interval);
37
- //
38
- if (this.allowExecutionIdentification && this.tracker) await this.tracker.stopTracking();
39
+ //Tracker
40
+ if (this.allowExecutionIdentification && this.tracker) await this.tracker.trackExecAndDrain(true);
39
41
  }
40
42
  //Executions
41
43
  async _execute(executionFunc) {
@@ -103,7 +103,7 @@ export default class IKTransaction {
103
103
  await safeExecution();
104
104
  await this.logger.flushLogs();
105
105
  //Tracker
106
- if (this.tracker) await this.tracker.stopTracking();
106
+ if (this.tracker) await this.tracker.trackExecAndDrain(true);
107
107
  } catch (e) {
108
108
  this.logger.error('Exception when flushing logs.');
109
109
  this.logger.exception(e);
@@ -8,7 +8,9 @@ export default class IKExecutionTracker {
8
8
  constructor(config, context, db) {
9
9
  this.context = context;
10
10
  this.db = db;
11
+ this.config = config;
11
12
  this.startedOn = Date.now();
13
+ this.drainedExecution = false;
12
14
  if (config) this.client = this._getClient(config);
13
15
  this.claimers = {};
14
16
  }
@@ -16,6 +18,10 @@ export default class IKExecutionTracker {
16
18
  appendClaimer(value, key) { this.claimers[value] = key; }
17
19
  appendEvent(event) { this.client.appendEvent(event); }
18
20
  //
21
+ resetExecutionTrace() {
22
+ this.startedOn = Date.now();
23
+ this.drainedExecution = false;
24
+ }
19
25
  async quickDrain() {
20
26
  try {
21
27
  //Check for client and claimers
@@ -24,8 +30,11 @@ export default class IKExecutionTracker {
24
30
  await this.client.drain(this.claimers);
25
31
  } catch (e) { console.error(`Error while draining tracker events: ${e}`); }
26
32
  }
27
- async stopTracking() {
33
+ async trackExecAndDrain() {
28
34
  try {
35
+ //Check
36
+ if (this.drainedExecution) return;
37
+ this.drainedExecution = true;
29
38
  //Check for client and claimers
30
39
  if (!this.client || Object.keys(this.claimers).length == 0) return; //disabled
31
40
  //detect execution and log (ECS or lambda)