Last active
December 22, 2021 16:24
-
-
Save rveitch/24fce9fe626b9dda6fdfaa6b00c04c87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const clusterUrls = ['http://127.0.0.1:9000', 'https://badserver.fail']; | |
(async () => { | |
const healthCheckPromises = clusterUrls.map((clusterUrl) => checkServerHealth(clusterUrl)); | |
const results = await Promise.allSettled(healthCheckPromises); | |
return results; | |
})(); | |
/** | |
* Initials health check per-cluster | |
*/ | |
async function checkServerHealth(serverUrl) { | |
const nodesHealth = await clusterNodesHealthCheck(); | |
const clusterMetadata = await fetchClusterMetadata(); | |
const statusObject = { | |
...clusterMetadata, | |
...nodesHealth, | |
} | |
return reportToRedis(statusObject); | |
} | |
/** | |
* Fetches node health for each node on a cluster | |
*/ | |
async function clusterNodesHealthCheck(clusterUrl) { | |
const clusterNodes = await fetchClusterNodes(); | |
return Promise.allSettled(clusterUrls.map((clusterUrl) => fetchNodeHealth(clusterUrl))); | |
} | |
async function fetchClusterNodes() {} | |
async function fetchNodeHealth() {} | |
async function fetchClusterMetadata() {} | |
async function reportToRedis() { /* Upsert results to redis */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment