@autofleet/rabbit 2.1.2 → 2.1.4

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 CHANGED
@@ -68,7 +68,7 @@ class RabbitMq {
68
68
  const { properties: { timestamp, headers } } = msg;
69
69
  if (shouldUpdateRedisTimestamp && timestamp && (headers === null || headers === void 0 ? void 0 : headers.redisTimestampValidationKey) && this.redisClient) {
70
70
  const parsedTimestamp = parseInt(timestamp, 10);
71
- yield this.redisClient.setAsync(headers.redisTimestampValidationKey, parsedTimestamp);
71
+ yield this.redisClient.setAsync(headers.redisTimestampValidationKey, parsedTimestamp, 'EX', 3600);
72
72
  }
73
73
  });
74
74
  this.nack = (channel, queue, options, deadQueueOptions) => (msg, { skipRetry = false, } = {}) => __awaiter(this, void 0, void 0, function* () {
@@ -222,8 +222,7 @@ class RabbitMq {
222
222
  outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
223
223
  const shouldConsume = yield this.shouldConsumeMessageByTimestamp(parsedMessage);
224
224
  if (!shouldConsume) {
225
- this.ack(channel);
226
- return;
225
+ return this.ack(channel)(msg);
227
226
  }
228
227
  callback(parsedMessage, this.ack(channel, true), this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }));
229
228
  })),
package/dist/redis.js CHANGED
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const redis_1 = __importDefault(require("redis"));
7
6
  const bluebird_1 = __importDefault(require("bluebird"));
8
- bluebird_1.default.promisifyAll(redis_1.default.RedisClient.prototype);
9
- bluebird_1.default.promisifyAll(redis_1.default.Multi.prototype);
10
- const getRedisInstance = (config) => redis_1.default.createClient(config);
7
+ const redis = require('redis');
8
+ bluebird_1.default.promisifyAll(redis.RedisClient.prototype);
9
+ bluebird_1.default.promisifyAll(redis.Multi.prototype);
10
+ const getRedisInstance = (config) => redis.createClient(config);
11
11
  exports.default = getRedisInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,7 +17,6 @@
17
17
  "dependencies": {
18
18
  "@types/amqp-connection-manager": "^2.0.10",
19
19
  "@types/amqplib": "^0.5.16",
20
- "@types/redis": "^2.8.32",
21
20
  "@types/uuid": "^8.3.3",
22
21
  "amqp-connection-manager": "^3.2.1",
23
22
  "amqplib": "^0.6.0",
package/src/index.ts CHANGED
@@ -6,7 +6,6 @@ import { ConfirmChannel, Options } from 'amqplib';
6
6
  import { AmqpConnectionManager, ChannelWrapper, connect } from 'amqp-connection-manager';
7
7
  import { EventEmitter } from 'events';
8
8
  import { newTrace, traceTypes } from '@autofleet/outbreak';
9
- import { RedisClient } from 'redis';
10
9
  import RabbitError from './rabbitError';
11
10
  import getRedisInstance, { RedisConfig } from './redis';
12
11
 
@@ -121,7 +120,7 @@ class RabbitMq implements IAfRabbitMq {
121
120
  const { properties: { timestamp, headers } } = msg;
122
121
  if (shouldUpdateRedisTimestamp && timestamp && headers?.redisTimestampValidationKey && this.redisClient) {
123
122
  const parsedTimestamp = parseInt(timestamp, 10);
124
- await this.redisClient.setAsync(headers.redisTimestampValidationKey, parsedTimestamp);
123
+ await this.redisClient.setAsync(headers.redisTimestampValidationKey, parsedTimestamp, 'EX', 3600);
125
124
  }
126
125
  }
127
126
 
@@ -254,8 +253,7 @@ class RabbitMq implements IAfRabbitMq {
254
253
  newTrace(traceTypes.RABBIT);
255
254
  const shouldConsume = await this.shouldConsumeMessageByTimestamp(parsedMessage);
256
255
  if (!shouldConsume) {
257
- this.ack(channel);
258
- return;
256
+ return this.ack(channel)(msg);
259
257
  }
260
258
  callback(parsedMessage, this.ack(channel, true), this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }));
261
259
  },
package/src/redis.ts CHANGED
@@ -1,6 +1,7 @@
1
- import redis from 'redis';
2
1
  import bluebird from 'bluebird';
3
2
 
3
+ const redis = require('redis');
4
+
4
5
  bluebird.promisifyAll(redis.RedisClient.prototype);
5
6
  bluebird.promisifyAll(redis.Multi.prototype);
6
7