dt-common-device 8.0.7 → 8.0.9
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/config/config.d.ts +1 -0
- package/dist/config/config.js +3 -2
- package/dist/constants/Event.d.ts +1 -0
- package/dist/constants/Event.js +1 -0
- package/dist/db/redis.js +17 -2
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
package/dist/config/config.js
CHANGED
|
@@ -270,11 +270,12 @@ function getDTApiKey() {
|
|
|
270
270
|
function getRedisDbHostAndPort() {
|
|
271
271
|
const host = process.env.REDIS_HOST;
|
|
272
272
|
const port = process.env.REDIS_PORT;
|
|
273
|
-
|
|
273
|
+
const nodeEnv = process.env.NODE_ENV;
|
|
274
|
+
if (!host || !port || !nodeEnv) {
|
|
274
275
|
getConfig().LOGGER.error("REDIS_HOST and REDIS_PORT must be set in environment variables");
|
|
275
276
|
throw new Error("dt-common-device: REDIS_HOST and REDIS_PORT must be set in environment variables");
|
|
276
277
|
}
|
|
277
|
-
return { host, port: Number(port) };
|
|
278
|
+
return { host, port: Number(port), nodeEnv };
|
|
278
279
|
}
|
|
279
280
|
/**
|
|
280
281
|
* Graceful shutdown function
|
package/dist/constants/Event.js
CHANGED
|
@@ -260,6 +260,7 @@ exports.DT_EVENT_TYPES = {
|
|
|
260
260
|
SCHEDULE_CODES: "heartbeat.lock.schedule_codes",
|
|
261
261
|
MARKED_TO_DELETE_CODES: "heartbeat.lock.marked_to_delete_codes",
|
|
262
262
|
UNSET_CODES: "heartbeat.lock.unset_codes",
|
|
263
|
+
ORPHANED_GUEST_CODES: "heartbeat.lock.orphaned_guest_codes",
|
|
263
264
|
},
|
|
264
265
|
STOPPED: "heartbeat.stopped",
|
|
265
266
|
COMPLETED: "heartbeat.completed",
|
package/dist/db/redis.js
CHANGED
|
@@ -4,21 +4,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getRedisClient = getRedisClient;
|
|
7
|
+
//Singleton pattern to ensure only one Redis client instance is create only once and shared across the application
|
|
7
8
|
const config_1 = require("../config/config");
|
|
8
9
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
9
10
|
let redisClient = null;
|
|
10
|
-
//Singleton pattern to ensure only one Redis client instance is create only once and shared across the application
|
|
11
11
|
function getRedisClient() {
|
|
12
12
|
if (!redisClient) {
|
|
13
|
-
const { host, port } = (0, config_1.getRedisDbHostAndPort)();
|
|
13
|
+
const { host, port, nodeEnv } = (0, config_1.getRedisDbHostAndPort)();
|
|
14
|
+
const isGreenEcs = nodeEnv === "green-ecs";
|
|
14
15
|
redisClient = new ioredis_1.default({
|
|
15
16
|
host,
|
|
16
17
|
port,
|
|
18
|
+
tls: isGreenEcs
|
|
19
|
+
? {
|
|
20
|
+
rejectUnauthorized: false, // required for AWS ElastiCache TLS
|
|
21
|
+
}
|
|
22
|
+
: undefined, // no TLS for dev/QA/UAT
|
|
23
|
+
lazyConnect: true,
|
|
24
|
+
enableReadyCheck: false,
|
|
25
|
+
connectTimeout: 10000,
|
|
17
26
|
maxRetriesPerRequest: null,
|
|
18
27
|
});
|
|
19
28
|
redisClient.on("error", (error) => {
|
|
20
29
|
console.error("Redis error:", error);
|
|
21
30
|
});
|
|
31
|
+
redisClient.on("connect", () => {
|
|
32
|
+
console.log("✅ Redis connected successfully");
|
|
33
|
+
});
|
|
34
|
+
redisClient.on("ready", () => {
|
|
35
|
+
console.log("✅ Redis ready for operations");
|
|
36
|
+
});
|
|
22
37
|
}
|
|
23
38
|
return redisClient;
|
|
24
39
|
}
|