@hastehaul/common 2.0.44 → 2.0.46

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,8 @@
1
1
  import IORedis from 'ioredis';
2
- declare class RedisClient {
2
+ export declare class RedisClient {
3
3
  private master;
4
4
  private replicas;
5
+ private _redisClient?;
5
6
  private static instance;
6
7
  private constructor();
7
8
  static getInstance(masterHost: string, replicaHosts: string[]): RedisClient;
@@ -14,4 +15,3 @@ declare class RedisClient {
14
15
  setex(key: string, value: string, seconds: number): Promise<any>;
15
16
  quit(): void;
16
17
  }
17
- export default RedisClient;
@@ -32,11 +32,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.RedisClient = void 0;
35
36
  const ioredis_1 = __importStar(require("ioredis"));
36
37
  class RedisClient {
37
38
  constructor(masterHost, replicaHosts) {
38
39
  this.master = new ioredis_1.default({ host: masterHost, port: 6379 });
39
40
  this.replicas = replicaHosts.map(replicaHost => new ioredis_1.default({ host: replicaHost, port: 6379 }));
41
+ this.master.on("connect", () => console.info("Redis Server Connected!"));
42
+ this.master.on("error", (error) => console.error("Error in Redis", error.message));
43
+ this.replicas.forEach((client) => {
44
+ client.on('connect', () => console.log('Replica connected'));
45
+ client.on('error', (error) => console.log('Replica connected', error.message));
46
+ });
40
47
  }
41
48
  // get client(): IORedis {
42
49
  // if(!this._redisClient) throw new Error("Cannot access Redis Client before connecting")
@@ -83,6 +90,5 @@ class RedisClient {
83
90
  this.replicas.forEach(replica => replica.quit());
84
91
  }
85
92
  }
86
- // private _redisClient?: IORedis
93
+ exports.RedisClient = RedisClient;
87
94
  RedisClient.instance = null;
88
- exports.default = RedisClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "2.0.44",
3
+ "version": "2.0.46",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",