@autofleet/rabbit 3.0.1-alpha7 → 3.0.1-alpha9
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 +3 -6
- package/dist/lib/consts.d.ts +1 -0
- package/dist/lib/consts.js +1 -0
- package/dist/lib/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/index.ts +6 -7
- package/src/lib/consts.ts +1 -0
- package/src/lib/types.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -321,7 +321,7 @@ class RabbitMq {
|
|
|
321
321
|
async consumeFromRabbit(queue, callback, options) {
|
|
322
322
|
const optionsWithDefaults = { ...consts_1.DEFAULT_OPTIONS, ...options };
|
|
323
323
|
RabbitMq.validateName('queue', queue);
|
|
324
|
-
const { limit, deadMessageTtl, useConsumeWithLock, lockTimeout, auditContext, } = optionsWithDefaults;
|
|
324
|
+
const { limit, deadMessageTtl, useConsumeWithLock, lockTimeout, auditContext, enableRabbitTrace, } = optionsWithDefaults;
|
|
325
325
|
if (useConsumeWithLock) {
|
|
326
326
|
if (!this.redisLock) {
|
|
327
327
|
throw new Error('Usage of consumeWithLock requires RedisInstance');
|
|
@@ -342,11 +342,8 @@ class RabbitMq {
|
|
|
342
342
|
const trace = zehut_1.newTrace(zehut_1.traceTypes.RABBIT);
|
|
343
343
|
trace?.context?.set(consts_1.TRACING_HEADER, traceId);
|
|
344
344
|
}
|
|
345
|
-
else if (userId) {
|
|
346
|
-
|
|
347
|
-
trace?.context?.set(consts_1.USER_OBJECT, {
|
|
348
|
-
id: userId,
|
|
349
|
-
});
|
|
345
|
+
else if (userId && enableRabbitTrace) {
|
|
346
|
+
await zehut_1.setRabbitTrace(userId);
|
|
350
347
|
}
|
|
351
348
|
if (auditContext) {
|
|
352
349
|
auditContext(queue);
|
package/dist/lib/consts.d.ts
CHANGED
package/dist/lib/consts.js
CHANGED
package/dist/lib/types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface ConsumeOptions {
|
|
|
18
18
|
lockTimeout?: number;
|
|
19
19
|
useConsumeWithLock?: boolean;
|
|
20
20
|
auditContext?: any;
|
|
21
|
+
enableRabbitTrace?: boolean;
|
|
21
22
|
}
|
|
22
23
|
export declare type CallbackFunction = (msg: ConsumeMessage, ack: any, nack: any) => Promise<any>;
|
|
23
24
|
export declare type newChannelOpts = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/rabbit",
|
|
3
|
-
"version": "3.0.1-
|
|
3
|
+
"version": "3.0.1-alpha9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@autofleet/logger": "^1.2.8",
|
|
19
|
-
"@autofleet/zehut": "^3.0.1",
|
|
19
|
+
"@autofleet/zehut": "^3.0.1-alpha3",
|
|
20
20
|
"@types/amqplib": "0.8.2",
|
|
21
21
|
"@types/uuid": "^8.3.3",
|
|
22
22
|
"amqp-connection-manager": "4.1.9",
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,9 @@ import { AmqpConnectionManager, ChannelWrapper, connect } from 'amqp-connection-
|
|
|
8
8
|
import {
|
|
9
9
|
ConfirmChannel, ConsumeMessage, Options, Replies,
|
|
10
10
|
} from 'amqplib';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getCurrentPayload, newTrace, traceTypes, setRabbitTrace,
|
|
13
|
+
} from '@autofleet/zehut';
|
|
12
14
|
import logger from './logger';
|
|
13
15
|
import RabbitError from './lib/rabbitError';
|
|
14
16
|
import getRedisInstance, { RedisConfig } from './lib/redis';
|
|
@@ -459,7 +461,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
459
461
|
const optionsWithDefaults = { ...DEFAULT_OPTIONS, ...options };
|
|
460
462
|
RabbitMq.validateName('queue', queue);
|
|
461
463
|
const {
|
|
462
|
-
limit, deadMessageTtl, useConsumeWithLock, lockTimeout, auditContext,
|
|
464
|
+
limit, deadMessageTtl, useConsumeWithLock, lockTimeout, auditContext, enableRabbitTrace,
|
|
463
465
|
} = optionsWithDefaults;
|
|
464
466
|
if (useConsumeWithLock) {
|
|
465
467
|
if (!this.redisLock) {
|
|
@@ -483,11 +485,8 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
483
485
|
if (traceId) {
|
|
484
486
|
const trace = newTrace(traceTypes.RABBIT);
|
|
485
487
|
(trace as any)?.context?.set(TRACING_HEADER, traceId);
|
|
486
|
-
} else if (userId) {
|
|
487
|
-
|
|
488
|
-
(trace as any)?.context?.set(USER_OBJECT, {
|
|
489
|
-
id: userId,
|
|
490
|
-
});
|
|
488
|
+
} else if (userId && enableRabbitTrace) {
|
|
489
|
+
await setRabbitTrace(userId);
|
|
491
490
|
}
|
|
492
491
|
|
|
493
492
|
if (auditContext) {
|
package/src/lib/consts.ts
CHANGED
package/src/lib/types.ts
CHANGED