Skip to content

Instantly share code, notes, and snippets.

@rveitch
Last active December 22, 2021 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rveitch/24fce9fe626b9dda6fdfaa6b00c04c87 to your computer and use it in GitHub Desktop.
Save rveitch/24fce9fe626b9dda6fdfaa6b00c04c87 to your computer and use it in GitHub Desktop.
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