use polyoxide_core::{HttpClient, RequestError};
use std::time::{Duration, Instant};
use crate::error::GammaError;
#[derive(Clone)]
pub struct Health {
pub(crate) http_client: HttpClient,
}
impl Health {
pub async fn ping(&self) -> Result<Duration, GammaError> {
let start = Instant::now();
let response = self
.http_client
.client
.get(self.http_client.base_url.clone())
.send()
.await?;
let latency = start.elapsed();
if !response.status().is_success() {
return Err(GammaError::from_response(response).await);
}
Ok(latency)
}
}