use std::borrow::Cow;
use async_trait::async_trait;
pub type BoxedReadinessSource = Box<dyn std::error::Error + Send + Sync>;
#[derive(Debug, thiserror::Error)]
pub enum ReadinessFailure {
#[error("{reason}")]
Unready { reason: Cow<'static, str> },
#[error("readiness check failed")]
Failed(#[source] BoxedReadinessSource),
}
#[async_trait]
pub trait ReadinessCheck: Send + Sync {
fn name(&self) -> &'static str;
async fn check(&self) -> Result<(), ReadinessFailure>;
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum MetricKind {
Counter,
Gauge,
Histogram { buckets: &'static [f64] },
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct MetricDescriptor {
pub name: &'static str,
pub help: &'static str,
pub kind: MetricKind,
}