The timeout duration for the health check request in milliseconds.
A function that takes an endpoint object and returns a promise resolving to the endpoint's health status, including its address and response time.
import { getEndpointHealthStatus, getEndpoints, NETWORK_TYPE, ENDPOINT_TYPE } from "@akashnetwork/akashjs/build/network";
const checkEndpointHealth = async () => {
try {
const endpoints = await getEndpoints(NETWORK_TYPE.MAINNET, ENDPOINT_TYPE.RPC);
const healthStatusPromises = endpoints.map(endpoint => getEndpointHealthStatus(800)(endpoint));
const healthStatuses = await Promise.all(healthStatusPromises);
console.log("Endpoint Health Statuses:");
healthStatuses.forEach(status => {
console.log(`Address: ${status.address}, Response Time: ${status.responseTime !== null ? status.responseTime + 'ms' : 'Unresponsive'}`);
});
} catch (error) {
console.error("Error checking endpoint health:", error);
}
};
checkEndpointHealth();
Creates a function to check the health status of an endpoint.