@cap-js-community/event-queue 1.2.2 → 1.2.3
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.2.
|
|
3
|
+
"version": "1.2.3",
|
|
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": [
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"node": ">=18"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"redis": "4.6.
|
|
45
|
+
"redis": "4.6.13",
|
|
46
46
|
"verror": "1.10.1",
|
|
47
47
|
"yaml": "2.3.4"
|
|
48
48
|
},
|
|
@@ -21,6 +21,8 @@ const SELECT_LIMIT_EVENTS_PER_TICK = 100;
|
|
|
21
21
|
const TRIES_FOR_EXCEEDED_EVENTS = 3;
|
|
22
22
|
const EVENT_START_AFTER_HEADROOM = 3 * 1000;
|
|
23
23
|
|
|
24
|
+
let serviceBindingCache = {};
|
|
25
|
+
|
|
24
26
|
class EventQueueProcessorBase {
|
|
25
27
|
#eventsWithExceededTries = [];
|
|
26
28
|
#exceededTriesExceeded = [];
|
|
@@ -673,16 +675,14 @@ class EventQueueProcessorBase {
|
|
|
673
675
|
});
|
|
674
676
|
let txSchema, serviceManagerSchema;
|
|
675
677
|
try {
|
|
676
|
-
const mtxServiceManager = require("@sap/cds-mtxs/srv/plugins/hana/srv-mgr");
|
|
677
678
|
const schemaPromise = tx.run("SELECT CURRENT_SCHEMA FROM DUMMY");
|
|
678
|
-
const
|
|
679
|
-
const [schema, serviceManagerBindings] = await Promise.allSettled([schemaPromise, serviceManagerBindingsPromise]);
|
|
679
|
+
const [schema, serviceManagerBindings] = await Promise.allSettled([schemaPromise, this.#getServiceBindings()]);
|
|
680
680
|
if (schema.reason) {
|
|
681
681
|
errorHandler(schema.reason);
|
|
682
682
|
return;
|
|
683
683
|
}
|
|
684
684
|
if (serviceManagerBindings.reason) {
|
|
685
|
-
errorHandler(
|
|
685
|
+
errorHandler(serviceManagerBindings.reason);
|
|
686
686
|
return;
|
|
687
687
|
}
|
|
688
688
|
|
|
@@ -699,6 +699,16 @@ class EventQueueProcessorBase {
|
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
701
|
|
|
702
|
+
async #getServiceBindings() {
|
|
703
|
+
if (serviceBindingCache && serviceBindingCache.exipreTs >= Date.now()) {
|
|
704
|
+
return serviceBindingCache.value;
|
|
705
|
+
}
|
|
706
|
+
const mtxServiceManager = require("@sap/cds-mtxs/srv/plugins/hana/srv-mgr");
|
|
707
|
+
serviceBindingCache.value = await mtxServiceManager.getAll();
|
|
708
|
+
serviceBindingCache.exipreTs = Date.now() + 10 * 60 * 1000;
|
|
709
|
+
return serviceBindingCache.value;
|
|
710
|
+
}
|
|
711
|
+
|
|
702
712
|
async #selectLastSuccessfulPeriodicTimestamp() {
|
|
703
713
|
const entry = await SELECT.one
|
|
704
714
|
.from(this.#config.tableNameEventQueue)
|