@hastehaul/common 2.0.40 → 2.0.41
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.
@@ -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 =
|
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();
|