@hastehaul/common 2.0.39 → 2.0.41

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ export declare class RedisWrapper {
22
22
  * @param {string} host - The Redis server host address (default is "customer-redis-srv").
23
23
  * @param {number} port - The Redis server port number (default is 6379).
24
24
  */
25
- connect(host?: string, port?: number): Promise<void>;
25
+ connect(host?: string, port?: number, useSentinel?: boolean): Promise<void>;
26
26
  }
27
27
  /**
28
28
  * Singleton instance of the RedisWrapper class to provide a centralized Redis client connection.
@@ -42,10 +42,25 @@ class RedisWrapper {
42
42
  * @param {string} host - The Redis server host address (default is "customer-redis-srv").
43
43
  * @param {number} port - The Redis server port number (default is 6379).
44
44
  */
45
- connect(host, port) {
45
+ connect(host, port, useSentinel = false) {
46
46
  return __awaiter(this, void 0, void 0, function* () {
47
47
  return new Promise((resolve, reject) => {
48
- this._redisClient = new ioredis_1.default({ host: host || this.host, port: port || this.port, maxRetriesPerRequest: null });
48
+ this._redisClient = useSentinel
49
+ ? new ioredis_1.default({
50
+ maxRetriesPerRequest: null,
51
+ sentinels: [
52
+ {
53
+ host: host || this.host,
54
+ port: port || this.port,
55
+ },
56
+ ],
57
+ name: "backend-redis"
58
+ })
59
+ : new ioredis_1.default({
60
+ host: host || this.host,
61
+ port: port || this.port,
62
+ maxRetriesPerRequest: null,
63
+ });
49
64
  this._redisClient.on("connect", () => {
50
65
  console.info("Redis Server Connected!");
51
66
  resolve();
@@ -14,7 +14,7 @@ class AbstractJobQueue {
14
14
  */
15
15
  constructor(queueName) {
16
16
  // Initialize the job queue with the provided name and a Redis connection from the redisWrapper.
17
- this.que = new bullmq_1.Queue(queueName, { connection: redis_connection_wrapper_1.redisWrapper.client });
17
+ this.que = new bullmq_1.Queue(queueName, { connection: redis_connection_wrapper_1.redisWrapper.client, prefix: '{BULLMQ}' });
18
18
  }
19
19
  }
20
20
  exports.AbstractJobQueue = AbstractJobQueue;
@@ -17,6 +17,7 @@ class AbstractWorker {
17
17
  this.worker = new bullmq_1.Worker(queueName, this.process.bind(this), {
18
18
  connection: redis_connection_wrapper_1.redisWrapper.client,
19
19
  autorun: false,
20
+ prefix: '{BULLMQ}',
20
21
  });
21
22
  // Handle errors that may occur during job processing.
22
23
  this.worker.on("error", (err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "2.0.39",
3
+ "version": "2.0.41",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",