@cap-js-community/event-queue 1.6.3 → 1.6.4
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.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"description": "An event queue that enables secure transactional processing of asynchronous and periodic events, featuring instant event processing with Redis Pub/Sub and load distribution across all application instances.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -63,9 +63,6 @@
|
|
|
63
63
|
"prettier": "^2.8.8",
|
|
64
64
|
"sqlite3": "^5.1.7"
|
|
65
65
|
},
|
|
66
|
-
"peerDependencies": {
|
|
67
|
-
"@cap-js/telemetry": "^0.2.2"
|
|
68
|
-
},
|
|
69
66
|
"homepage": "https://cap-js-community.github.io/event-queue/",
|
|
70
67
|
"repository": {
|
|
71
68
|
"type": "git",
|
|
@@ -920,7 +920,7 @@ class EventQueueProcessorBase {
|
|
|
920
920
|
return;
|
|
921
921
|
}
|
|
922
922
|
try {
|
|
923
|
-
await trace(this.baseContext, "
|
|
923
|
+
await trace(this.baseContext, "release-lock", async () => {
|
|
924
924
|
await distributedLock.releaseLock(this.context, [this.#eventType, this.#eventSubType].join("##"));
|
|
925
925
|
});
|
|
926
926
|
} catch (err) {
|
|
@@ -1160,6 +1160,10 @@ class EventQueueProcessorBase {
|
|
|
1160
1160
|
get isPeriodicEvent() {
|
|
1161
1161
|
return this.#eventConfig.isPeriodic;
|
|
1162
1162
|
}
|
|
1163
|
+
|
|
1164
|
+
get eventConfig() {
|
|
1165
|
+
return this.#eventConfig;
|
|
1166
|
+
}
|
|
1163
1167
|
}
|
|
1164
1168
|
|
|
1165
1169
|
module.exports = EventQueueProcessorBase;
|
package/src/config.js
CHANGED
|
@@ -282,6 +282,7 @@ class Config {
|
|
|
282
282
|
checkForNextChunk: config.checkForNextChunk,
|
|
283
283
|
deleteFinishedEventsAfterDays: config.deleteFinishedEventsAfterDays,
|
|
284
284
|
appNames: config.appNames,
|
|
285
|
+
useEventQueueUser: config.useEventQueueUser,
|
|
285
286
|
internalEvent: true,
|
|
286
287
|
};
|
|
287
288
|
eventConfig._appNameMap = eventConfig.appNames
|
package/src/index.d.ts
CHANGED
|
@@ -63,6 +63,24 @@ type EventConfigType = {
|
|
|
63
63
|
isPeriodic: boolean;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
export type EventConfig = {
|
|
67
|
+
type: string;
|
|
68
|
+
subType: string;
|
|
69
|
+
load: number;
|
|
70
|
+
impl: string;
|
|
71
|
+
selectMaxChunkSize: number | undefined;
|
|
72
|
+
parallelEventProcessing: boolean;
|
|
73
|
+
retryAttempts: number | undefined;
|
|
74
|
+
transactionMode: string | undefined;
|
|
75
|
+
processAfterCommit: boolean | undefined;
|
|
76
|
+
eventOutdatedCheck: boolean | undefined;
|
|
77
|
+
checkForNextChunk: boolean | undefined;
|
|
78
|
+
deleteFinishedEventsAfterDays: number | undefined;
|
|
79
|
+
appNames: string[] | undefined;
|
|
80
|
+
useEventQueueUser: boolean | undefined;
|
|
81
|
+
internalEvent: true;
|
|
82
|
+
};
|
|
83
|
+
|
|
66
84
|
// Define Status Type
|
|
67
85
|
type Status = 0 | 1 | 2 | 3 | 4;
|
|
68
86
|
|
|
@@ -126,6 +144,7 @@ export declare class EventQueueProcessorBase {
|
|
|
126
144
|
get isPeriodicEvent(): boolean;
|
|
127
145
|
get eventType(): String;
|
|
128
146
|
get eventSubType(): String;
|
|
147
|
+
get eventConfig(): EventConfig;
|
|
129
148
|
}
|
|
130
149
|
|
|
131
150
|
export function publishEvent(
|
|
@@ -5,6 +5,7 @@ const cds = require("@sap/cds");
|
|
|
5
5
|
const EventQueueBaseClass = require("../EventQueueProcessorBase");
|
|
6
6
|
const { EventProcessingStatus } = require("../constants");
|
|
7
7
|
const common = require("../shared/common");
|
|
8
|
+
const config = require("../config");
|
|
8
9
|
|
|
9
10
|
const COMPONENT_NAME = "/eventQueue/outbox/generic";
|
|
10
11
|
|
|
@@ -18,7 +19,8 @@ class EventQueueGenericOutboxHandler extends EventQueueBaseClass {
|
|
|
18
19
|
let status = EventProcessingStatus.Done;
|
|
19
20
|
try {
|
|
20
21
|
const service = await cds.connect.to(this.eventSubType);
|
|
21
|
-
const
|
|
22
|
+
const { useEventQueueUser } = this.eventConfig;
|
|
23
|
+
const userId = useEventQueueUser ? config.userId : payload.contextUser;
|
|
22
24
|
const msg = payload._fromSend ? new cds.Request(payload) : new cds.Event(payload);
|
|
23
25
|
const invocationFn = payload._fromSend ? "send" : "emit";
|
|
24
26
|
delete msg._fromSend;
|