@autofleet/rabbit 2.5.0-beta.5 → 2.5.0-beta.7
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 +4 -28
- package/package.json +2 -2
- package/src/index.ts +3 -27
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,11 +124,7 @@ class RabbitMq {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
static getPublishOptions(customHeaders = {}) {
|
|
127
|
-
const trace =
|
|
128
|
-
logger_1.default.info('ANKRI getPublishOptions', {
|
|
129
|
-
trace,
|
|
130
|
-
context: Array.from(trace.context),
|
|
131
|
-
});
|
|
127
|
+
const trace = outbreak_1.getCurrentContext();
|
|
132
128
|
return {
|
|
133
129
|
timestamp: moment_1.default().unix(),
|
|
134
130
|
headers: {
|
|
@@ -260,8 +256,8 @@ class RabbitMq {
|
|
|
260
256
|
return null;
|
|
261
257
|
}
|
|
262
258
|
const traceId = msg.properties.headers[TRACING_HEADER];
|
|
263
|
-
const trace =
|
|
264
|
-
trace
|
|
259
|
+
const trace = outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
|
|
260
|
+
trace?.context?.set(TRACING_HEADER, traceId);
|
|
265
261
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
266
262
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
267
263
|
const shouldConsume = await this.shouldConsumeMessageByTimestamp(parsedMessage);
|
|
@@ -297,17 +293,7 @@ class RabbitMq {
|
|
|
297
293
|
});
|
|
298
294
|
}
|
|
299
295
|
async publish(exchange, content, customHeaders) {
|
|
300
|
-
const trace = zehut_1.getCurrentPayload();
|
|
301
|
-
logger_1.default.info('ANKRI publish', {
|
|
302
|
-
trace,
|
|
303
|
-
context: Array.from(trace.context),
|
|
304
|
-
});
|
|
305
296
|
return wrapSetImmediate(async () => {
|
|
306
|
-
const trace2 = zehut_1.getCurrentPayload();
|
|
307
|
-
logger_1.default.info('ANKRI publish inside wrapSetImmediate', {
|
|
308
|
-
trace: trace2,
|
|
309
|
-
context: Array.from(trace.context),
|
|
310
|
-
});
|
|
311
297
|
RabbitMq.validateName('exchange', exchange);
|
|
312
298
|
const channel = await this.assertChannel();
|
|
313
299
|
await this.assertExchange(exchange);
|
|
@@ -315,17 +301,7 @@ class RabbitMq {
|
|
|
315
301
|
});
|
|
316
302
|
}
|
|
317
303
|
async sendToQueue(queue, content, options, customHeaders) {
|
|
318
|
-
const trace = zehut_1.getCurrentPayload();
|
|
319
|
-
logger_1.default.info('ANKRI sendToQueue', {
|
|
320
|
-
trace,
|
|
321
|
-
context: Array.from(trace.context),
|
|
322
|
-
});
|
|
323
304
|
return wrapSetImmediate(async () => {
|
|
324
|
-
const trace2 = zehut_1.getCurrentPayload();
|
|
325
|
-
logger_1.default.info('ANKRI wrapSetImmediate inside wrapSetImmediate', {
|
|
326
|
-
trace: trace2,
|
|
327
|
-
context: Array.from(trace.context),
|
|
328
|
-
});
|
|
329
305
|
RabbitMq.validateName('queue', queue);
|
|
330
306
|
const channel = await this.assertChannel();
|
|
331
307
|
await this.assertQueue(queue, options);
|
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.7",
|
|
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,11 +103,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
static getPublishOptions(customHeaders: CustomMessageHeaders = {}) {
|
|
106
|
-
const trace =
|
|
107
|
-
logger.info('ANKRI getPublishOptions', {
|
|
108
|
-
trace,
|
|
109
|
-
context: Array.from(trace.context),
|
|
110
|
-
});
|
|
106
|
+
const trace = getCurrentContext();
|
|
111
107
|
return {
|
|
112
108
|
timestamp: moment().unix(),
|
|
113
109
|
headers: {
|
|
@@ -369,7 +365,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
369
365
|
|
|
370
366
|
const traceId = msg.properties.headers[TRACING_HEADER];
|
|
371
367
|
const trace = newTrace(traceTypes.RABBIT);
|
|
372
|
-
trace
|
|
368
|
+
(trace as any)?.context?.set(TRACING_HEADER, traceId);
|
|
373
369
|
|
|
374
370
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
375
371
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
@@ -417,17 +413,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
417
413
|
}
|
|
418
414
|
|
|
419
415
|
async publish(exchange: string, content: any, customHeaders?: any) : Promise<boolean> {
|
|
420
|
-
const trace = getCurrentPayload();
|
|
421
|
-
logger.info('ANKRI publish', {
|
|
422
|
-
trace,
|
|
423
|
-
context: Array.from(trace.context),
|
|
424
|
-
});
|
|
425
416
|
return wrapSetImmediate(async () => {
|
|
426
|
-
const trace2 = getCurrentPayload();
|
|
427
|
-
logger.info('ANKRI publish inside wrapSetImmediate', {
|
|
428
|
-
trace: trace2,
|
|
429
|
-
context: Array.from(trace.context),
|
|
430
|
-
});
|
|
431
417
|
RabbitMq.validateName('exchange', exchange);
|
|
432
418
|
const channel: ChannelWrapper = await this.assertChannel();
|
|
433
419
|
await this.assertExchange(exchange);
|
|
@@ -438,17 +424,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
438
424
|
}
|
|
439
425
|
|
|
440
426
|
async sendToQueue(queue: string, content: any, options?: any, customHeaders?: any) : Promise<boolean> {
|
|
441
|
-
const trace = getCurrentPayload();
|
|
442
|
-
logger.info('ANKRI sendToQueue', {
|
|
443
|
-
trace,
|
|
444
|
-
context: Array.from(trace.context),
|
|
445
|
-
});
|
|
446
427
|
return wrapSetImmediate(async () => {
|
|
447
|
-
const trace2 = getCurrentPayload();
|
|
448
|
-
logger.info('ANKRI wrapSetImmediate inside wrapSetImmediate', {
|
|
449
|
-
trace: trace2,
|
|
450
|
-
context: Array.from(trace.context),
|
|
451
|
-
});
|
|
452
428
|
RabbitMq.validateName('queue', queue);
|
|
453
429
|
const channel: ChannelWrapper = await this.assertChannel();
|
|
454
430
|
await this.assertQueue(queue, options);
|