@autofleet/rabbit 2.5.0-beta.2 → 2.5.0-beta.3

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.d.ts CHANGED
@@ -3,7 +3,6 @@ import { Options, ConsumeMessage } from 'amqplib';
3
3
  import { AmqpConnectionManager, ChannelWrapper } from 'amqp-connection-manager';
4
4
  import { EventEmitter } from 'events';
5
5
  import { RedisConfig } from './redis';
6
- declare const TRACING_HEADER = "x-trace-id";
7
6
  export interface IAfRabbitMq {
8
7
  ack: any;
9
8
  nack: any;
@@ -38,6 +37,7 @@ declare type CallbackFunction = (msg: ConsumeMessage, ack: Function, nack: Funct
38
37
  export interface AfRabbitOptions {
39
38
  disableReconnect: boolean;
40
39
  }
40
+ declare const TRACING_HEADER = "x-trace-id";
41
41
  declare class RabbitMq implements IAfRabbitMq {
42
42
  static parseMsg(msg: any): any;
43
43
  static validateName(type: string, name: string): void;
package/dist/index.js CHANGED
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  // eslint-disable-next-line max-classes-per-file
8
8
  const moment_1 = __importDefault(require("moment"));
9
9
  const redis_lock_1 = __importDefault(require("redis-lock"));
10
- const shortid_1 = __importDefault(require("shortid"));
11
10
  const amqp_connection_manager_1 = require("amqp-connection-manager");
12
11
  const events_1 = require("events");
13
12
  const util_1 = require("util");
@@ -15,10 +14,10 @@ const zehut_1 = require("@autofleet/zehut");
15
14
  const logger_1 = __importDefault(require("./logger"));
16
15
  const rabbitError_1 = __importDefault(require("./rabbitError"));
17
16
  const redis_1 = __importDefault(require("./redis"));
18
- const TRACING_HEADER = 'x-trace-id';
19
17
  const DEFAULT_DEAD_TTL_TWO_DAYS = 60000 * 60 * 48;
20
18
  const DEFAULT_LOCK_TIMEOUT = 1000 * 5;
21
19
  const RETRY_HEADER = 'x-retry-count';
20
+ const TRACING_HEADER = 'x-trace-id';
22
21
  const DEFAULT_USE_CONSUME_WITH_LOCK = false;
23
22
  const defaultOptions = {
24
23
  limit: 1,
@@ -256,11 +255,8 @@ class RabbitMq {
256
255
  if (!msg) {
257
256
  return null;
258
257
  }
258
+ const traceId = msg.properties.headers[TRACING_HEADER];
259
259
  const trace = zehut_1.newTrace(zehut_1.traceTypes.RABBIT);
260
- let traceId = msg.properties.headers[TRACING_HEADER];
261
- if (typeof traceId === 'undefined') {
262
- traceId = shortid_1.default.generate();
263
- }
264
260
  trace.context.set(TRACING_HEADER, traceId);
265
261
  const parsedMessage = RabbitMq.parseMsg(msg);
266
262
  const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "2.5.0-beta.2",
3
+ "version": "2.5.0-beta.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -12,8 +12,6 @@ import logger from './logger';
12
12
  import RabbitError from './rabbitError';
13
13
  import getRedisInstance, { RedisConfig } from './redis';
14
14
 
15
- const TRACING_HEADER = 'x-trace-id';
16
-
17
15
  export interface IAfRabbitMq {
18
16
  ack: any;
19
17
  nack: any;
@@ -58,6 +56,7 @@ export interface AfRabbitOptions {
58
56
  const DEFAULT_DEAD_TTL_TWO_DAYS = 60000 * 60 * 48;
59
57
  const DEFAULT_LOCK_TIMEOUT = 1000 * 5;
60
58
  const RETRY_HEADER = 'x-retry-count';
59
+ const TRACING_HEADER = 'x-trace-id';
61
60
  const DEFAULT_USE_CONSUME_WITH_LOCK = false;
62
61
 
63
62
  const defaultOptions = {
@@ -365,11 +364,8 @@ class RabbitMq implements IAfRabbitMq {
365
364
  return null;
366
365
  }
367
366
 
367
+ const traceId = msg.properties.headers[TRACING_HEADER];
368
368
  const trace = newTrace(traceTypes.RABBIT);
369
- let traceId = msg.properties.headers[TRACING_HEADER];
370
- if (typeof traceId === 'undefined') {
371
- traceId = shortid.generate();
372
- }
373
369
  trace.context.set(TRACING_HEADER, traceId);
374
370
 
375
371
  const parsedMessage = RabbitMq.parseMsg(msg);