logos-delivery/waku/node/health_monitor/protocol_health.nim
Fabiana Cecin 1fb4d1eab0
feat: implement Waku API Health spec (#3689)
* Fix protocol strength metric to consider connected peers only
* Remove polling loop; event-driven node connection health updates
* Remove 10s WakuRelay topic health polling loop; now event-driven
* Change NodeHealthStatus to ConnectionStatus
* Change new nodeState (rest API /health) field to connectionStatus
* Add getSyncProtocolHealthInfo and getSyncNodeHealthReport
* Add ConnectionStatusChangeEvent
* Add RequestHealthReport
* Refactor sync/async protocol health queries in the health monitor
* Add EventRelayTopicHealthChange
* Add EventWakuPeer emitted by PeerManager
* Add Edge support for topics health requests and events
* Rename "RelayTopic" -> "Topic"
* Add RequestContentTopicsHealth sync request
* Add EventContentTopicHealthChange
* Rename RequestTopicsHealth -> RequestShardTopicsHealth
* Remove health check gating from checkApiAvailability
* Add basic health smoke tests
* Other misc improvements, refactors, fixes

Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com>
Co-authored-by: Ivan FB <128452529+Ivansete-status@users.noreply.github.com>
2026-02-12 14:52:39 -03:00

49 lines
1.4 KiB
Nim

import std/[options, strformat]
import ./health_status
import waku/common/waku_protocol
export waku_protocol
type ProtocolHealth* = object
protocol*: string
health*: HealthStatus
desc*: Option[string] ## describes why a certain protocol is considered `NOT_READY`
proc notReady*(p: var ProtocolHealth, desc: string): ProtocolHealth =
p.health = HealthStatus.NOT_READY
p.desc = some(desc)
return p
proc ready*(p: var ProtocolHealth): ProtocolHealth =
p.health = HealthStatus.READY
p.desc = none[string]()
return p
proc notMounted*(p: var ProtocolHealth): ProtocolHealth =
p.health = HealthStatus.NOT_MOUNTED
p.desc = none[string]()
return p
proc synchronizing*(p: var ProtocolHealth): ProtocolHealth =
p.health = HealthStatus.SYNCHRONIZING
p.desc = none[string]()
return p
proc initializing*(p: var ProtocolHealth): ProtocolHealth =
p.health = HealthStatus.INITIALIZING
p.desc = none[string]()
return p
proc shuttingDown*(p: var ProtocolHealth): ProtocolHealth =
p.health = HealthStatus.SHUTTING_DOWN
p.desc = none[string]()
return p
proc `$`*(p: ProtocolHealth): string =
return fmt"protocol: {p.protocol}, health: {p.health}, description: {p.desc}"
proc init*(p: typedesc[ProtocolHealth], protocol: WakuProtocol): ProtocolHealth =
return ProtocolHealth(
protocol: $protocol, health: HealthStatus.NOT_MOUNTED, desc: none[string]()
)