@ikonintegration/ikapi 3.1.19 → 3.1.23

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.19",
3
+ "version": "3.1.23",
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.131.0",
18
18
  "@aws-sdk/node-http-handler": "^3.127.0",
19
19
  "@aws-sdk/util-dynamodb": "^3.131.0",
20
- "@ikonintegration/mod-resources-tracker-client": "0.0.12",
20
+ "@ikonintegration/mod-resources-tracker-client": "0.0.13",
21
21
  "abind": "^1.0.5",
22
22
  "bluebird": "^3.7.2",
23
23
  "email-templates": "^8.0.8",
@@ -15,6 +15,7 @@ import IKExecutionTracker from '../Tracker/IKExecutionTracker';
15
15
  export default class IKProcess {
16
16
  constructor(config, interval) {
17
17
  this._config = config;
18
+ this.allowExecutionIdentification = false;
18
19
  this.interval = interval;
19
20
  this.logger = new IKLogger(config.logger, Utils.logLevel());
20
21
  this.publisher = new IKPublisher(config.publisher);
@@ -33,6 +34,8 @@ export default class IKProcess {
33
34
  setInterval( async () => {
34
35
  await this._execute(executionFunc);
35
36
  }, this.interval);
37
+ //
38
+ if (this.allowExecutionIdentification && this.tracker) await this.tracker.stopTracking();
36
39
  }
37
40
  //Executions
38
41
  async _execute(executionFunc) {
@@ -45,14 +48,15 @@ export default class IKProcess {
45
48
  await executionFunc(this);
46
49
  //Commit DB
47
50
  if (this.db) await this.db.commit();
51
+ //Tracker
52
+ if (this.tracker) await this.tracker.quickDrain();
53
+ //
48
54
  executionFailed = false;
49
55
  } catch (e) { /*EXECUTION FAIL*/
50
56
  this.logger.error('Exception when executing main request code. Rolling back DB!');
51
57
  this.logger.exception(e);
52
58
  //Rollback DB
53
59
  if (this.db) await this.db.rollback();
54
- //Tracker
55
- if (this.tracker) await this.tracker.stopTracking();
56
60
  } return executionFailed;
57
61
  }
58
62
  /* DB drivers support */
@@ -16,6 +16,14 @@ export default class IKExecutionTracker {
16
16
  appendClaimer(value, key) { this.claimers[value] = key; }
17
17
  appendEvent(event) { this.client.appendEvent(event); }
18
18
  //
19
+ async quickDrain() {
20
+ try {
21
+ //Check for client and claimers
22
+ if (!this.client || Object.keys(this.claimers).length == 0) return; //disabled
23
+ //drain stats
24
+ await this.client.drain(this.claimers);
25
+ } catch (e) { console.error(`Error while draining tracker events: ${e}`); }
26
+ }
19
27
  async stopTracking() {
20
28
  try {
21
29
  //Check for client and claimers