Chore:extracted the redis monitor to a different monitoring type (#4393)

Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
Frank Elsinga
2025-11-16 04:55:38 +08:00
committed by GitHub
co-authored by Louis Lam
parent 319edddae5
commit dda1a3f442
10 changed files with 180 additions and 105 deletions
-39
View File
@@ -20,7 +20,6 @@ const { Settings } = require("./settings");
const grpc = require("@grpc/grpc-js");
const protojs = require("protobufjs");
const RadiusClient = require("./radius-client");
const redis = require("redis");
const oidc = require("openid-client");
const tls = require("tls");
const { exists } = require("fs");
@@ -523,44 +522,6 @@ exports.radius = function (
});
};
/**
* Redis server ping
* @param {string} dsn The redis connection string
* @param {boolean} rejectUnauthorized If false, allows unverified server certificates.
* @returns {Promise<any>} Response from server
*/
exports.redisPingAsync = function (dsn, rejectUnauthorized) {
return new Promise((resolve, reject) => {
const client = redis.createClient({
url: dsn,
socket: {
rejectUnauthorized
}
});
client.on("error", (err) => {
if (client.isOpen) {
client.disconnect();
}
reject(err);
});
client.connect().then(() => {
if (!client.isOpen) {
client.emit("error", new Error("connection isn't open"));
}
client.ping().then((res, err) => {
if (client.isOpen) {
client.disconnect();
}
if (err) {
reject(err);
} else {
resolve(res);
}
}).catch(error => reject(error));
});
});
};
/**
* Retrieve value of setting based on key
* @param {string} key Key of setting to retrieve