@cap-js-community/event-queue 0.1.56 → 0.1.58

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/README.md CHANGED
@@ -13,7 +13,7 @@ enhancing the overall performance of your application.
13
13
 
14
14
  ## Getting started
15
15
 
16
- - Run `npm add @cap-community/event-queue` in `@sap/cds` project
16
+ - Run `npm add @cap-js-community/event-queue` in `@sap/cds` project
17
17
  - Activate the cds-plugin in the cds section of the package.sjon
18
18
 
19
19
  ### As cds-plugin
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cap-js-community/event-queue",
3
- "version": "0.1.56",
4
- "description": "event queue for cds",
3
+ "version": "0.1.58",
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": [
7
7
  "src",
@@ -9,6 +9,16 @@
9
9
  "cds-plugin.js",
10
10
  "index.cds"
11
11
  ],
12
+ "keywords": [
13
+ "CAP",
14
+ "CDS",
15
+ "messaging",
16
+ "async",
17
+ "redis",
18
+ "load-balancing",
19
+ "eventing",
20
+ "multi-tenancy"
21
+ ],
12
22
  "scripts": {
13
23
  "test:unit": "jest --testPathIgnorePatterns=\"/test-integration/\"",
14
24
  "test:integration": "jest --testPathIgnorePatterns=\"/test/\" --runInBand --forceExit",
@@ -20,7 +30,7 @@
20
30
  "lint:ci": "npm run eslint:ci && npm run prettier:ci",
21
31
  "eslint": "eslint --fix .",
22
32
  "eslint:ci": "eslint .",
23
- "prettier": "prettier --write --loglevel error .",
33
+ "prettier": "prettier --write --log-level error .",
24
34
  "prettier:ci": "prettier --check .",
25
35
  "prepareRelease": "npm prune --production",
26
36
  "docs": "cd docs && bundle exec jekyll serve",
@@ -31,24 +41,22 @@
31
41
  "node": ">=16"
32
42
  },
33
43
  "dependencies": {
34
- "uuid": "9.0.0",
35
- "redis": "4.6.8",
44
+ "redis": "4.6.10",
36
45
  "verror": "1.10.1",
37
- "yaml": "2.3.2"
46
+ "yaml": "2.3.3"
38
47
  },
39
48
  "devDependencies": {
40
- "@sap/eslint-plugin-cds": "2.6.3",
41
- "@sap/cds-dk": "7.1.1",
42
- "hdb": "0.19.5",
49
+ "@sap/cds": "7.3.1",
50
+ "@sap/cds-dk": "7.3.1",
51
+ "eslint": "8.52.0",
52
+ "eslint-config-prettier": "9.0.0",
53
+ "eslint-plugin-jest": "27.6.0",
43
54
  "eslint-plugin-node": "11.1.0",
44
- "sqlite3": "5.1.6",
45
55
  "express": "4.18.2",
46
- "@sap/cds": "7.1.2",
47
- "eslint": "8.48.0",
48
- "eslint-config-prettier": "9.0.0",
49
- "eslint-plugin-jest": "27.2.3",
50
- "jest": "29.6.4",
51
- "prettier": "3.0.3"
56
+ "hdb": "0.19.6",
57
+ "jest": "29.7.0",
58
+ "prettier": "3.0.3",
59
+ "sqlite3": "5.1.6"
52
60
  },
53
61
  "homepage": "https://cap-js-community.github.io/event-queue/",
54
62
  "repository": {
@@ -47,7 +47,9 @@ const publishEvent = async (tenantId, type, subType) => {
47
47
  const logger = cds.log(COMPONENT_NAME);
48
48
  const configInstance = config.getConfigInstance();
49
49
  if (!configInstance.redisEnabled) {
50
- await _handleEventInternally(tenantId, type, subType);
50
+ if (configInstance.registerAsEventProcessor) {
51
+ await _handleEventInternally(tenantId, type, subType);
52
+ }
51
53
  return;
52
54
  }
53
55
  try {
@@ -86,7 +88,7 @@ const _handleEventInternally = async (tenantId, type, subType) => {
86
88
  // NOTE: we need this because of logging otherwise logs would not contain the subdomain
87
89
  http: { req: { authInfo: { getSubdomain: () => subdomain } } },
88
90
  });
89
- processEventQueue(context, type, subType);
91
+ getWorkerPoolInstance().addToQueue(async () => processEventQueue(context, type, subType));
90
92
  };
91
93
 
92
94
  module.exports = {
package/src/runner.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const uuid = require("uuid");
3
+ const { randomUUID } = require("crypto");
4
4
 
5
5
  const eventQueueConfig = require("./config");
6
6
  const { eventQueueRunner } = require("./processEventQueue");
@@ -130,7 +130,7 @@ const _executeRunForTenant = async (tenantId, runId) => {
130
130
 
131
131
  const _acquireRunId = async (context) => {
132
132
  const configInstance = eventQueueConfig.getConfigInstance();
133
- let runId = uuid.v4();
133
+ let runId = randomUUID();
134
134
  const couldSetValue = await distributedLock.setValueWithExpire(context, EVENT_QUEUE_RUN_ID, runId, {
135
135
  tenantScoped: false,
136
136
  expiryTime: configInstance.runInterval * 0.95,