@imqueue/core 2.0.16 → 2.0.17
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/debug_getter.d.ts +9 -0
- package/debug_listener.d.ts +1 -0
- package/package.json +2 -2
- package/src/IMessageQueue.d.ts +11 -1
- package/src/RedisQueue.js +18 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imqueue/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "Simple JSON-based messaging queue for inter service communication",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"message-queue",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"author": "imqueue.com <support@imqueue.com> (https://imqueue.com)",
|
|
39
39
|
"license": "GPL-3.0-only",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"ioredis": "^5.
|
|
41
|
+
"ioredis": "^5.8.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@eslint/js": "^9.33.0",
|
package/src/IMessageQueue.d.ts
CHANGED
|
@@ -244,11 +244,21 @@ export interface IMQOptions extends Partial<IMessageQueueConnection> {
|
|
|
244
244
|
*/
|
|
245
245
|
clusterManagers?: ClusterManager[];
|
|
246
246
|
/**
|
|
247
|
-
* Enables/disables verbose logging
|
|
247
|
+
* Enables/disables verbose logging
|
|
248
248
|
*
|
|
249
|
+
* @default false
|
|
249
250
|
* @type {boolean}
|
|
250
251
|
*/
|
|
251
252
|
verbose?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Enables/disables extended verbose logging. The output may contain
|
|
255
|
+
* sensitive information, so use it with caution. Does not work if a verbose
|
|
256
|
+
* option is disabled.
|
|
257
|
+
*
|
|
258
|
+
* @default false
|
|
259
|
+
* @type {boolean}
|
|
260
|
+
*/
|
|
261
|
+
verboseExtended?: boolean;
|
|
252
262
|
}
|
|
253
263
|
export interface EventMap {
|
|
254
264
|
message: [data: any, id: string, from: string];
|
package/src/RedisQueue.js
CHANGED
|
@@ -57,6 +57,8 @@ exports.DEFAULT_IMQ_OPTIONS = {
|
|
|
57
57
|
safeDeliveryTtl: 5000,
|
|
58
58
|
useGzip: false,
|
|
59
59
|
watcherCheckDelay: 5000,
|
|
60
|
+
verbose: false,
|
|
61
|
+
verboseExtended: false,
|
|
60
62
|
};
|
|
61
63
|
exports.IMQ_SHUTDOWN_TIMEOUT = +(process.env.IMQ_SHUTDOWN_TIMEOUT || 1000);
|
|
62
64
|
/**
|
|
@@ -172,9 +174,16 @@ class RedisQueue extends events_1.EventEmitter {
|
|
|
172
174
|
this.redisKey = `${this.options.host}:${this.options.port}`;
|
|
173
175
|
this.verbose(`Initializing queue on ${this.options.host}:${this.options.port} with prefix ${this.options.prefix} and safeDelivery = ${this.options.safeDelivery}, and safeDeliveryTtl = ${this.options.safeDeliveryTtl}, and watcherCheckDelay = ${this.options.watcherCheckDelay}, and useGzip = ${this.options.useGzip}`);
|
|
174
176
|
}
|
|
175
|
-
verbose(message) {
|
|
177
|
+
verbose(message, sensitiveMessage, sensitiveOnly) {
|
|
178
|
+
if (sensitiveOnly && !this.options.verboseExtended) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
176
181
|
if (this.options.verbose) {
|
|
177
|
-
|
|
182
|
+
const text = `[IMQ-CORE][${this.name}]: ${message}`;
|
|
183
|
+
const fullText = this.options.verboseExtended
|
|
184
|
+
? `${text}${sensitiveMessage}`
|
|
185
|
+
: text;
|
|
186
|
+
this.logger.info(fullText);
|
|
178
187
|
}
|
|
179
188
|
}
|
|
180
189
|
/**
|
|
@@ -205,7 +214,7 @@ class RedisQueue extends events_1.EventEmitter {
|
|
|
205
214
|
if (ch === fcn && typeof handler === 'function') {
|
|
206
215
|
handler(JSON.parse(message));
|
|
207
216
|
}
|
|
208
|
-
this.verbose(`Received message from ${ch} channel
|
|
217
|
+
this.verbose(`Received message from ${ch} channel`, `, data: ${JSON.stringify(message)}`);
|
|
209
218
|
});
|
|
210
219
|
this.verbose(`Subscribed to ${channel} channel`);
|
|
211
220
|
}
|
|
@@ -246,8 +255,7 @@ class RedisQueue extends events_1.EventEmitter {
|
|
|
246
255
|
const jsonData = JSON.stringify(data);
|
|
247
256
|
const name = toName || this.name;
|
|
248
257
|
await this.writer.publish(`${this.options.prefix}:${name}`, jsonData);
|
|
249
|
-
this.verbose(`Published message to ${name} channel
|
|
250
|
-
`);
|
|
258
|
+
this.verbose(`Published message to ${name} channel`, `, data: ${jsonData}`);
|
|
251
259
|
}
|
|
252
260
|
/**
|
|
253
261
|
* Initializes and starts current queue routines
|
|
@@ -328,6 +336,7 @@ class RedisQueue extends events_1.EventEmitter {
|
|
|
328
336
|
const data = { id, message, from: this.name };
|
|
329
337
|
const key = `${this.options.prefix}:${toQueue}`;
|
|
330
338
|
const packet = this.pack(data);
|
|
339
|
+
this.verbose('Message send', `: ${packet}`, true);
|
|
331
340
|
const cb = (error, op) => {
|
|
332
341
|
// istanbul ignore next
|
|
333
342
|
if (error) {
|
|
@@ -338,10 +347,10 @@ class RedisQueue extends events_1.EventEmitter {
|
|
|
338
347
|
}
|
|
339
348
|
};
|
|
340
349
|
if (delay) {
|
|
341
|
-
await this.writer.zadd(`${key}:delayed`, Date.now() + delay, packet, (
|
|
350
|
+
await this.writer.zadd(`${key}:delayed`, Date.now() + delay, packet, (e) => {
|
|
342
351
|
// istanbul ignore next
|
|
343
|
-
if (
|
|
344
|
-
cb(
|
|
352
|
+
if (e) {
|
|
353
|
+
cb(e, 'ZADD');
|
|
345
354
|
return;
|
|
346
355
|
}
|
|
347
356
|
this.writer.set(`${key}:${id}:ttl`, '', 'PX', delay, 'NX', (err) => {
|
|
@@ -715,6 +724,7 @@ class RedisQueue extends events_1.EventEmitter {
|
|
|
715
724
|
const { id, message, from } = this.unpack(data);
|
|
716
725
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
717
726
|
this.emit('message', message, id, from);
|
|
727
|
+
this.verbose('Message received', `: ${data}`, true);
|
|
718
728
|
}
|
|
719
729
|
catch (err) {
|
|
720
730
|
// istanbul ignore next
|