Danish Arora d464af3645
feat: node and protocols health (#2080)
* feat: introduce HealthManager

* feat: make health accessible on Waku object

* feat: update health from protocols

* chore: add access modifiers to healthmanager

* feat: use a HealthManager singleton

* chore: add tests for Filter, LightPush and Store

* feat: add overall node health

* chore: update protocol health to consider Store protocol

* chore: setup generic test utils instead of using filter utils

* tests: add a health status matrix check from 0-3

* chore: increase timeout for failing tests in CI
tests pass locally without an increased timeout, but fail in CI

* chore: move name inference to HealthManager

* tests: abstract away node creation and teardown utils

* fix: import
2024-07-27 18:27:54 +05:30

27 lines
685 B
TypeScript

import { Protocols } from "./protocols";
export enum HealthStatus {
Unhealthy = "Unhealthy",
MinimallyHealthy = "MinimallyHealthy",
SufficientlyHealthy = "SufficientlyHealthy"
}
export interface IHealthManager {
getHealthStatus: () => HealthStatus;
getProtocolStatus: (protocol: Protocols) => ProtocolHealth | undefined;
updateProtocolHealth: (multicodec: string, connectedPeers: number) => void;
}
export type NodeHealth = {
overallStatus: HealthStatus;
protocolStatuses: ProtocolsHealthStatus;
};
export type ProtocolHealth = {
name: Protocols;
status: HealthStatus;
lastUpdate: Date;
};
export type ProtocolsHealthStatus = Map<Protocols, ProtocolHealth>;