template-saas/apps/backend/node_modules/bullmq/dist/cjs/classes/queue-events-producer.js
rckrdmrd 50a821a415
Some checks failed
CI / Backend CI (push) Has been cancelled
CI / Frontend CI (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / CI Summary (push) Has been cancelled
[SIMCO-V38] feat: Actualizar a SIMCO v3.8.0
- HERENCIA-SIMCO.md actualizado con directivas v3.7 y v3.8
- Actualizaciones de configuracion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 08:53:08 -06:00

42 lines
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueueEventsProducer = void 0;
const tslib_1 = require("tslib");
const queue_base_1 = require("./queue-base");
/**
* The QueueEventsProducer class is used for publishing custom events.
*/
class QueueEventsProducer extends queue_base_1.QueueBase {
constructor(name, opts = {
connection: {},
}, Connection) {
super(name, Object.assign({ blockingConnection: false }, opts), Connection);
this.opts = opts;
}
/**
* Publish custom event to be processed in QueueEvents.
* @param argsObj - Event payload
* @param maxEvents - Max quantity of events to be saved
*/
async publishEvent(argsObj, maxEvents = 1000) {
const client = await this.client;
const key = this.keys.events;
const { eventName } = argsObj, restArgs = tslib_1.__rest(argsObj, ["eventName"]);
const args = ['MAXLEN', '~', maxEvents, '*', 'event', eventName];
for (const [key, value] of Object.entries(restArgs)) {
args.push(key, value);
}
await client.xadd(key, ...args);
}
/**
* Closes the connection and returns a promise that resolves when the connection is closed.
*/
async close() {
if (!this.closing) {
this.closing = this.connection.close();
}
await this.closing;
}
}
exports.QueueEventsProducer = QueueEventsProducer;
//# sourceMappingURL=queue-events-producer.js.map