@cap-js-community/event-queue 1.0.0 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js-community/event-queue",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "An event queue that enables secure transactional processing of asynchronous events, featuring instant event processing with Redis Pub/Sub and load distribution across all application instances.",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -47,17 +47,17 @@
47
47
  "yaml": "2.3.4"
48
48
  },
49
49
  "devDependencies": {
50
- "@sap/cds": "7.5.0",
50
+ "@sap/cds": "7.5.1",
51
51
  "@sap/cds-dk": "7.5.0",
52
52
  "eslint": "8.56.0",
53
53
  "eslint-config-prettier": "9.1.0",
54
- "eslint-plugin-jest": "27.6.0",
54
+ "eslint-plugin-jest": "27.6.1",
55
55
  "eslint-plugin-node": "11.1.0",
56
56
  "express": "4.18.2",
57
57
  "hdb": "0.19.7",
58
58
  "jest": "29.7.0",
59
59
  "prettier": "2.8.8",
60
- "sqlite3": "5.1.6"
60
+ "sqlite3": "5.1.7-rc.0"
61
61
  },
62
62
  "homepage": "https://cap-js-community.github.io/event-queue/",
63
63
  "repository": {
@@ -131,7 +131,7 @@ class EventQueueProcessorBase {
131
131
 
132
132
  endPerformanceTracerEvents() {
133
133
  this.__performanceLoggerEvents?.endPerformanceTrace(
134
- { threshold: 50 },
134
+ { threshold: this.#config.thresholdLoggingEventProcessing },
135
135
  {
136
136
  eventType: this.#eventType,
137
137
  eventSubType: this.#eventSubType,
@@ -141,7 +141,7 @@ class EventQueueProcessorBase {
141
141
 
142
142
  endPerformanceTracerPeriodicEvents() {
143
143
  this.__performanceLoggerPeriodicEvents?.endPerformanceTrace(
144
- { threshold: 50 },
144
+ { threshold: this.#config.thresholdLoggingEventProcessing },
145
145
  {
146
146
  eventType: this.#eventType,
147
147
  eventSubType: this.#eventSubType,
@@ -151,7 +151,7 @@ class EventQueueProcessorBase {
151
151
 
152
152
  endPerformanceTracerPreprocessing() {
153
153
  this.__performanceLoggerPreprocessing?.endPerformanceTrace(
154
- { threshold: 50 },
154
+ { threshold: this.#config.thresholdLoggingEventProcessing },
155
155
  {
156
156
  eventType: this.#eventType,
157
157
  eventSubType: this.#eventSubType,
package/src/config.js CHANGED
@@ -50,6 +50,7 @@ class Config {
50
50
  #updatePeriodicEvents;
51
51
  #blockedPeriodicEvents;
52
52
  #isPeriodicEventBlockedCb;
53
+ #thresholdLoggingEventProcessing;
53
54
  static #instance;
54
55
  constructor() {
55
56
  this.#logger = cds.log(COMPONENT_NAME);
@@ -396,6 +397,14 @@ class Config {
396
397
  return this.#registerAsEventProcessor;
397
398
  }
398
399
 
400
+ set thresholdLoggingEventProcessing(value) {
401
+ this.#thresholdLoggingEventProcessing = value;
402
+ }
403
+
404
+ get thresholdLoggingEventProcessing() {
405
+ return this.#thresholdLoggingEventProcessing;
406
+ }
407
+
399
408
  get isMultiTenancy() {
400
409
  return !!cds.requires.multitenancy;
401
410
  }
package/src/initialize.js CHANGED
@@ -34,6 +34,7 @@ const CONFIG_VARS = [
34
34
  ["disableRedis", false],
35
35
  ["skipCsnCheck", false],
36
36
  ["updatePeriodicEvents", true],
37
+ ["thresholdLoggingEventProcessing", 50],
37
38
  ];
38
39
 
39
40
  const initialize = async ({
@@ -47,6 +48,7 @@ const initialize = async ({
47
48
  disableRedis,
48
49
  skipCsnCheck,
49
50
  updatePeriodicEvents,
51
+ thresholdLoggingEventProcessing,
50
52
  } = {}) => {
51
53
  // TODO: initialize check:
52
54
  // - content of yaml check
@@ -67,7 +69,8 @@ const initialize = async ({
67
69
  tableNameEventLock,
68
70
  disableRedis,
69
71
  skipCsnCheck,
70
- updatePeriodicEvents
72
+ updatePeriodicEvents,
73
+ thresholdLoggingEventProcessing
71
74
  );
72
75
 
73
76
  const logger = cds.log(COMPONENT);
@@ -116,9 +116,13 @@ const getAllTenantIds = async () => {
116
116
  }
117
117
  const ssp = await cds.connect.to("cds.xt.SaasProvisioningService");
118
118
  const response = await ssp.get("/tenant");
119
- return response.map((tenant) => tenant.subscribedTenantId ?? tenant.tenant);
119
+ return response
120
+ .map((tenant) => tenant.subscribedTenantId ?? tenant.tenant)
121
+ .filter((tenantId) => !isFakeTenant(tenantId));
120
122
  };
121
123
 
124
+ const isFakeTenant = (tenantId) => /00000000-0000-4000-8000-\d{12}/.test(tenantId);
125
+
122
126
  module.exports = {
123
127
  executeInNewTransaction,
124
128
  TriggerRollback,