use actix_web::http::StatusCode;
use async_trait::async_trait;
use std::fmt::Debug;
#[async_trait]
pub trait Status: Send + Sync + Debug {
async fn healthz(&self) -> (String, StatusCode) {
("OK".to_string(), StatusCode::OK)
}
async fn metrics(&self) -> (String, StatusCode) {
let report = prometheus::TextEncoder::new()
.encode_to_string(&prometheus::default_registry().gather());
match report {
Ok(x) => (x, StatusCode::OK),
Err(e) => (format!("{e:?}"), StatusCode::INTERNAL_SERVER_ERROR),
}
}
}