Skip to main content

AirLibrary/Client/AirClient/
HealthCheck.rs

1//! `AirClient::HealthCheck` - pings the Air daemon and returns whether it
2//! reports itself healthy. Lightweight liveness probe; for runtime detail
3//! use [`AirClient::GetStatus`].
4
5use tonic::Request;
6
7use crate::{AirError, Client::AirClient::AirClient, Vine::Generated::air::HealthCheckRequest, dev_log};
8
9impl AirClient {
10	/// Performs a health check on the Air daemon.
11	pub async fn HealthCheck(&self) -> Result<bool, AirError> {
12		dev_log!("grpc", "[AirClient] Performing health check");
13
14		let RequestPayload = HealthCheckRequest {};
15
16		let Client = self
17			.Client()
18			.ok_or_else(|| AirError::Network("Air client not initialized".to_string()))?;
19
20		let mut ClientGuard = Client.lock().await;
21
22		match ClientGuard.health_check(Request::new(RequestPayload)).await {
23			Ok(Response) => {
24				let Response = Response.into_inner();
25
26				dev_log!("grpc", "[AirClient] Health check result: {}", Response.healthy);
27
28				Ok(Response.healthy)
29			},
30
31			Err(Status) => {
32				dev_log!("grpc", "error: [AirClient] Health check RPC error: {}", Status);
33
34				Err(AirError::Network(format!("Health check RPC error: {}", Status)))
35			},
36		}
37	}
38}