mcl_core_health (mcl_core v1.0.0)
View SourceTracks the health of the services this node hosts: one, or several in a release that bundles them (mcl-om#8). Their verdicts combine into the node's, and a failing one is named.
Exposed over HTTP by mcl_core_health_handler (Cowboy) at GET /health on the Unix socket health_socket, or else on port health_port (default 8470). Podman's HEALTHCHECK and systemd's EXEC_START Readiness mechanics use it.
Summary
Functions
The service's own health, degraded by a provider grant that is past waiting, an advertise loop that has gone stale, or a subscription that will not start. The service's verdict wins when it is not ok: it knows more about its own failure than the tables do. Otherwise the grant verdict wins over the advertise-liveness one (a provider that was never granted is degraded with the operator-actionable cause, whatever its loop did), and both over a subscription (a procedure nobody may call is a bigger hole than one topic nobody may publish to).
The verdict last computed (at registration, then by each /health request), without running the service's health probe again: what an open caller such as info may ask for as often as it likes.
ServiceMods own verdict as last computed, without probing again: what <org>/info reports for its service on a node hosting several.
Add ServiceMod to the services whose health this node reports. A service already there keeps its place.
The node's verdict from its services' own, given as {Name, Verdict} in boot order. One service: its verdict, as before a node could host more. Several: ok when every one is, else the first that is not, naming it ({degraded, {Name, Reason}}), so a 503 says which service to look at.
Stop reporting ServiceMod: a service that refused to start.
Functions
-spec combined(mcl_core_service:health(), mcl_core_service:health()) -> mcl_core_service:health().
The service's own health, degraded by a provider grant that is past waiting, an advertise loop that has gone stale, or a subscription that will not start. The service's verdict wins when it is not ok: it knows more about its own failure than the tables do. Otherwise the grant verdict wins over the advertise-liveness one (a provider that was never granted is degraded with the operator-actionable cause, whatever its loop did), and both over a subscription (a procedure nobody may call is a bigger hole than one topic nobody may publish to).
-spec last() -> mcl_core_service:health() | {error, not_booted}.
The verdict last computed (at registration, then by each /health request), without running the service's health probe again: what an open caller such as info may ask for as often as it likes.
-spec last(module()) -> mcl_core_service:health() | {error, not_booted}.
ServiceMods own verdict as last computed, without probing again: what <org>/info reports for its service on a node hosting several.
Add ServiceMod to the services whose health this node reports. A service already there keeps its place.
-spec services_verdict([{binary(), mcl_core_service:health()}]) -> mcl_core_service:health().
The node's verdict from its services' own, given as {Name, Verdict} in boot order. One service: its verdict, as before a node could host more. Several: ok when every one is, else the first that is not, naming it ({degraded, {Name, Reason}}), so a 503 says which service to look at.
-spec unregister(module()) -> ok.
Stop reporting ServiceMod: a service that refused to start.