New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cap-js-community/event-queue

Package Overview
Dependencies
Maintainers
7
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cap-js-community/event-queue - npm Package Compare versions

Comparing version 1.3.4 to 1.3.5

7

package.json
{
"name": "@cap-js-community/event-queue",
"version": "1.3.4",
"version": "1.3.5",
"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.",

@@ -73,2 +73,7 @@ "main": "src/index.js",

"disableRedis": false
},
"[test]": {
"registerAsEventProcessor": false,
"isRunnerDeactivated": true,
"updatePeriodicEvents": false
}

@@ -75,0 +80,0 @@ },

42

src/redisPubSub.js
"use strict";
const { promisify } = require("util");
const cds = require("@sap/cds");

@@ -13,3 +15,6 @@

const COMPONENT_NAME = "/eventQueue/redisPubSub";
const TRIES_FOR_PUBLISH_PERIODIC_EVENT = 10;
const SLEEP_TIME_FOR_PUBLISH_PERIODIC_EVENT = 30 * 1000;
const wait = promisify(setTimeout);
let subscriberClientPromise;

@@ -111,19 +116,30 @@

}
const result = await checkLockExistsAndReturnValue(
new cds.EventContext({ tenant: tenantId }),
[type, subType].join("##")
);
if (result) {
logger.debug("skip publish redis event as no lock is available", {
const eventConfig = config.getEventConfig(type, subType);
for (let i = 0; i < TRIES_FOR_PUBLISH_PERIODIC_EVENT; i++) {
const result = await checkLockExistsAndReturnValue(
new cds.EventContext({ tenant: tenantId }),
[type, subType].join("##")
);
if (result) {
logger.debug("skip publish redis event as no lock is available", {
type,
subType,
index: i,
isPeriodic: eventConfig.isPeriodic,
waitInterval: SLEEP_TIME_FOR_PUBLISH_PERIODIC_EVENT,
});
if (!eventConfig.isPeriodic) {
break;
}
await wait(SLEEP_TIME_FOR_PUBLISH_PERIODIC_EVENT);
continue;
}
logger.debug("publishing redis event", {
tenantId,
type,
subType,
});
return;
await redis.publishMessage(EVENT_MESSAGE_CHANNEL, JSON.stringify({ tenantId, type, subType }));
break;
}
logger.debug("publishing redis event", {
tenantId,
type,
subType,
});
await redis.publishMessage(EVENT_MESSAGE_CHANNEL, JSON.stringify({ tenantId, type, subType }));
} catch (err) {

@@ -130,0 +146,0 @@ logger.error("publish event failed!", err, {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc