Implement Node Monitor Service

- Check in with online nodes every n ms
- Update nodes that do not reply
- Added node object record helper
- Updated mysql wrapper for updating node info to accept bool or number
This commit is contained in:
Logan Cusano
2023-05-07 02:41:58 -04:00
parent 7b2215e9da
commit 9b2d0c4bbb
5 changed files with 141 additions and 51 deletions

View File

@@ -68,6 +68,7 @@ exports.addNewNode = (nodeObject, callback) => {
* @param callback Callback function
*/
exports.updateNodeInfo = (nodeObject, callback) => {
if(!nodeObject.id) throw new Error("Attempted to updated node without providing ID", nodeObject);
const name = nodeObject.name,
ip = nodeObject.ip,
port = nodeObject.port,
@@ -84,8 +85,8 @@ exports.updateNodeInfo = (nodeObject, callback) => {
nearbySystems = utils.JsonToBuffer(nearbySystems)
queryParams.push(`nearbySystems = '${nearbySystems}'`);
}
if (typeof online === "boolean") {
if (online) queryParams.push(`online = 1`);
if (typeof online === "boolean" || typeof online === "number") {
if (online || online === 1) queryParams.push(`online = 1`);
else queryParams.push(`online = 0`);
}