@hastehaul/common 2.0.40 → 2.0.43

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();
@@ -6,5 +6,5 @@ export declare function hasElapsed(expirationDate: Date): boolean;
6
6
  export declare function colorize(text: string, colorCode: number): string;
7
7
  export declare function formatDatetimeToHumanReadable(datetime: Date, format?: string): string;
8
8
  export declare function generateIdentifier(messageContent: string): string;
9
- export declare function getValueFromSettings(settings: Setting[], key: string, envVar: string, defaultValue: any): any;
9
+ export declare function getValueFromSettings(settings: Setting[], key: string, envVar?: string, defaultValue?: any): any;
10
10
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "2.0.40",
3
+ "version": "2.0.43",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",