@cap-js-community/event-queue 1.7.1 → 1.7.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 +1 -1
- package/src/initialize.js +6 -0
- package/src/periodicEvents.js +6 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js-community/event-queue",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
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",
|
package/src/initialize.js
CHANGED
|
@@ -71,6 +71,12 @@ const initialize = async (options = {}) => {
|
|
|
71
71
|
mixConfigVarsWithEnv(options);
|
|
72
72
|
|
|
73
73
|
const logger = cds.log(COMPONENT);
|
|
74
|
+
if (!config.useAsCAPOutbox && !config.configFilePath) {
|
|
75
|
+
logger.info(
|
|
76
|
+
"Event queue initialization skipped: no configFilePath provided, and event queue is not configured as a CAP outbox."
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
74
80
|
const redisEnabled = config.checkRedisEnabled();
|
|
75
81
|
let resolveFn;
|
|
76
82
|
let initFinished = new Promise((resolve) => (resolveFn = resolve));
|
package/src/periodicEvents.js
CHANGED
|
@@ -122,7 +122,7 @@ const _determineChangedCron = (existingEventsCron) => {
|
|
|
122
122
|
utc: config.utc,
|
|
123
123
|
...(config.useCronTimezone && { tz: eventConfig.cronTimezone }),
|
|
124
124
|
});
|
|
125
|
-
return cronExpression.next().getTime() - eventStartAfter.getTime() > 30 * 1000; // report as changed if diff created than 30 seconds
|
|
125
|
+
return Math.abs(cronExpression.next().getTime() - eventStartAfter.getTime()) > 30 * 1000; // report as changed if diff created than 30 seconds
|
|
126
126
|
});
|
|
127
127
|
};
|
|
128
128
|
|
|
@@ -133,12 +133,13 @@ const _insertPeriodEvents = async (tx, events, now) => {
|
|
|
133
133
|
const eventsToBeInserted = events.map((event) => {
|
|
134
134
|
const base = { type: event.type, subType: event.subType };
|
|
135
135
|
let startTime = now;
|
|
136
|
-
|
|
136
|
+
const config = eventConfig.getEventConfig(event.type, event.subType);
|
|
137
|
+
if (config.cron) {
|
|
137
138
|
startTime = cronParser
|
|
138
|
-
.parseExpression(
|
|
139
|
+
.parseExpression(config.cron, {
|
|
139
140
|
currentDate: now,
|
|
140
|
-
utc:
|
|
141
|
-
...(
|
|
141
|
+
utc: config.utc,
|
|
142
|
+
...(config.useCronTimezone && { tz: eventConfig.cronTimezone }),
|
|
142
143
|
})
|
|
143
144
|
.next();
|
|
144
145
|
}
|