pub const HEALTH_CHECK: &str = "machine HealthCheck<T> {\r\n state Healthy(status: T)\r\n state Degraded(status: T, failures: i64)\r\n state Unhealthy(reason: String)\r\n\r\n transition probe: Healthy -> Healthy | Degraded | Unhealthy\r\n transition recover: Degraded -> Healthy | Unhealthy\r\n\r\n async effect run_probe() -> Result<T, String>\r\n\r\n async on probe() {\r\n let result = perform run_probe();\r\n match result {\r\n Ok(next_status) => {\r\n goto Healthy(next_status);\r\n }\r\n Err(err) => {\r\n goto Degraded(status, 1);\r\n }\r\n }\r\n }\r\n\r\n async on recover() {\r\n let result = perform run_probe();\r\n match result {\r\n Ok(next_status) => {\r\n goto Healthy(next_status);\r\n }\r\n Err(err) => {\r\n goto Unhealthy(err);\r\n }\r\n }\r\n }\r\n}\r\n";Expand description
The Gust source for the HealthCheck machine.
Models service health monitoring with three states:
- Healthy – the service is operating normally.
- Degraded – some health checks are failing but the service is partially functional; tracks a failure count.
- Unhealthy – the service is down, with a reason string.
Generic over T for the health status payload type.