//! Health service — public API for the health domain.
//!
//! Exposes a single `check()` function that returns a [`HealthStatus`].
//! HTTP handlers call this instead of constructing the response inline.
//!
//! Conventions: `docs/architecture/service-modules.md`

pub mod check;
pub(super) mod io;

pub use check::HealthStatus;

// ── Error type ────────────────────────────────────────────────────────────────

/// Typed errors returned by `service::health` functions.
///
/// Health checks are currently infallible; this enum satisfies the module
/// convention and accommodates future error cases (e.g. dependency checks).
#[allow(dead_code)]
#[derive(Debug)]
pub enum Error {
    /// An internal error occurred during the health check.
    Internal(String),
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Internal(msg) => write!(f, "Health error: {msg}"),
        }
    }
}

// ── Public API ────────────────────────────────────────────────────────────────

/// Perform a health check and return the status.
pub fn check() -> HealthStatus {
    check::ok()
}
