rs-zero 0.1.1

Rust-first microservice framework inspired by go-zero engineering practices
Documentation
use std::{future::Future, net::SocketAddr};

/// Starts a tonic health server with graceful shutdown.
///
/// This helper gives the MVP a concrete, generated tonic service without
/// requiring application projects to define protobuf files immediately.
pub async fn serve_health_with_shutdown<F>(
    addr: SocketAddr,
    shutdown: F,
) -> Result<(), tonic::transport::Error>
where
    F: Future<Output = ()> + Send + 'static,
{
    let (_reporter, health_service) = tonic_health::server::health_reporter();

    tonic::transport::Server::builder()
        .add_service(health_service)
        .serve_with_shutdown(addr, shutdown)
        .await
}