@autofleet/rabbit 2.5.0-beta.5 → 2.5.0-beta.6
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/dist/index.js +9 -9
- package/package.json +2 -2
- package/src/index.ts +8 -8
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const redis_lock_1 = __importDefault(require("redis-lock"));
|
|
|
10
10
|
const amqp_connection_manager_1 = require("amqp-connection-manager");
|
|
11
11
|
const events_1 = require("events");
|
|
12
12
|
const util_1 = require("util");
|
|
13
|
-
const
|
|
13
|
+
const outbreak_1 = require("@autofleet/outbreak");
|
|
14
14
|
const logger_1 = __importDefault(require("./logger"));
|
|
15
15
|
const rabbitError_1 = __importDefault(require("./rabbitError"));
|
|
16
16
|
const redis_1 = __importDefault(require("./redis"));
|
|
@@ -124,7 +124,7 @@ class RabbitMq {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
static getPublishOptions(customHeaders = {}) {
|
|
127
|
-
const trace =
|
|
127
|
+
const trace = outbreak_1.getCurrentContext();
|
|
128
128
|
logger_1.default.info('ANKRI getPublishOptions', {
|
|
129
129
|
trace,
|
|
130
130
|
context: Array.from(trace.context),
|
|
@@ -260,8 +260,8 @@ class RabbitMq {
|
|
|
260
260
|
return null;
|
|
261
261
|
}
|
|
262
262
|
const traceId = msg.properties.headers[TRACING_HEADER];
|
|
263
|
-
const trace =
|
|
264
|
-
trace
|
|
263
|
+
const trace = outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
|
|
264
|
+
trace?.context?.set(TRACING_HEADER, traceId);
|
|
265
265
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
266
266
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
267
267
|
const shouldConsume = await this.shouldConsumeMessageByTimestamp(parsedMessage);
|
|
@@ -297,13 +297,13 @@ class RabbitMq {
|
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
async publish(exchange, content, customHeaders) {
|
|
300
|
-
const trace =
|
|
300
|
+
const trace = outbreak_1.getCurrentContext();
|
|
301
301
|
logger_1.default.info('ANKRI publish', {
|
|
302
302
|
trace,
|
|
303
303
|
context: Array.from(trace.context),
|
|
304
304
|
});
|
|
305
305
|
return wrapSetImmediate(async () => {
|
|
306
|
-
const trace2 =
|
|
306
|
+
const trace2 = outbreak_1.getCurrentContext();
|
|
307
307
|
logger_1.default.info('ANKRI publish inside wrapSetImmediate', {
|
|
308
308
|
trace: trace2,
|
|
309
309
|
context: Array.from(trace.context),
|
|
@@ -315,14 +315,14 @@ class RabbitMq {
|
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
async sendToQueue(queue, content, options, customHeaders) {
|
|
318
|
-
const trace =
|
|
318
|
+
const trace = outbreak_1.getCurrentContext();
|
|
319
319
|
logger_1.default.info('ANKRI sendToQueue', {
|
|
320
320
|
trace,
|
|
321
321
|
context: Array.from(trace.context),
|
|
322
322
|
});
|
|
323
323
|
return wrapSetImmediate(async () => {
|
|
324
|
-
const trace2 =
|
|
325
|
-
logger_1.default.info('ANKRI
|
|
324
|
+
const trace2 = outbreak_1.getCurrentContext();
|
|
325
|
+
logger_1.default.info('ANKRI sendToQueue inside wrapSetImmediate', {
|
|
326
326
|
trace: trace2,
|
|
327
327
|
context: Array.from(trace.context),
|
|
328
328
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/rabbit",
|
|
3
|
-
"version": "2.5.0-beta.
|
|
3
|
+
"version": "2.5.0-beta.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"uuid": "^8.3.2"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@autofleet/
|
|
30
|
+
"@autofleet/outbreak": "*"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/jest": "^26.0.23",
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ConfirmChannel, Options, ConsumeMessage } from 'amqplib';
|
|
|
6
6
|
import { AmqpConnectionManager, ChannelWrapper, connect } from 'amqp-connection-manager';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
8
8
|
import { promisify } from 'util';
|
|
9
|
-
import { traceTypes,
|
|
9
|
+
import { traceTypes, getCurrentContext, newTrace } from '@autofleet/outbreak';
|
|
10
10
|
import logger from './logger';
|
|
11
11
|
import RabbitError from './rabbitError';
|
|
12
12
|
import getRedisInstance, { RedisConfig } from './redis';
|
|
@@ -103,7 +103,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
static getPublishOptions(customHeaders: CustomMessageHeaders = {}) {
|
|
106
|
-
const trace =
|
|
106
|
+
const trace = getCurrentContext();
|
|
107
107
|
logger.info('ANKRI getPublishOptions', {
|
|
108
108
|
trace,
|
|
109
109
|
context: Array.from(trace.context),
|
|
@@ -369,7 +369,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
369
369
|
|
|
370
370
|
const traceId = msg.properties.headers[TRACING_HEADER];
|
|
371
371
|
const trace = newTrace(traceTypes.RABBIT);
|
|
372
|
-
trace
|
|
372
|
+
(trace as any)?.context?.set(TRACING_HEADER, traceId);
|
|
373
373
|
|
|
374
374
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
375
375
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
@@ -417,13 +417,13 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
async publish(exchange: string, content: any, customHeaders?: any) : Promise<boolean> {
|
|
420
|
-
const trace =
|
|
420
|
+
const trace = getCurrentContext();
|
|
421
421
|
logger.info('ANKRI publish', {
|
|
422
422
|
trace,
|
|
423
423
|
context: Array.from(trace.context),
|
|
424
424
|
});
|
|
425
425
|
return wrapSetImmediate(async () => {
|
|
426
|
-
const trace2 =
|
|
426
|
+
const trace2 = getCurrentContext();
|
|
427
427
|
logger.info('ANKRI publish inside wrapSetImmediate', {
|
|
428
428
|
trace: trace2,
|
|
429
429
|
context: Array.from(trace.context),
|
|
@@ -438,14 +438,14 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
async sendToQueue(queue: string, content: any, options?: any, customHeaders?: any) : Promise<boolean> {
|
|
441
|
-
const trace =
|
|
441
|
+
const trace = getCurrentContext();
|
|
442
442
|
logger.info('ANKRI sendToQueue', {
|
|
443
443
|
trace,
|
|
444
444
|
context: Array.from(trace.context),
|
|
445
445
|
});
|
|
446
446
|
return wrapSetImmediate(async () => {
|
|
447
|
-
const trace2 =
|
|
448
|
-
logger.info('ANKRI
|
|
447
|
+
const trace2 = getCurrentContext();
|
|
448
|
+
logger.info('ANKRI sendToQueue inside wrapSetImmediate', {
|
|
449
449
|
trace: trace2,
|
|
450
450
|
context: Array.from(trace.context),
|
|
451
451
|
});
|