pub struct HealthServer { /* private fields */ }Expand description
Health check HTTP server.
Provides HTTP endpoints for health monitoring, Kubernetes probes, and load balancer health checks.
Implementations§
Source§impl HealthServer
impl HealthServer
Sourcepub fn new(checker: Arc<HealthChecker>, config: HealthServerConfig) -> Self
pub fn new(checker: Arc<HealthChecker>, config: HealthServerConfig) -> Self
Creates a new HealthServer.
§Arguments
checker- Arc reference to the HealthCheckerconfig- Server configuration
§Example
use elara_runtime::health::HealthChecker;
use elara_runtime::health_server::{HealthServer, HealthServerConfig};
use std::sync::Arc;
use std::time::Duration;
let checker = Arc::new(HealthChecker::new(Duration::from_secs(30)));
let config = HealthServerConfig::default();
let server = HealthServer::new(checker, config);Sourcepub fn with_default_config(checker: Arc<HealthChecker>) -> Self
pub fn with_default_config(checker: Arc<HealthChecker>) -> Self
Creates a new HealthServer with default configuration.
Binds to 0.0.0.0:8080 by default.
Sourcepub async fn serve(self) -> Result<(), Error>
pub async fn serve(self) -> Result<(), Error>
Starts the health check HTTP server.
This method runs the server until it is shut down. It should be spawned as a background task in production deployments.
§Returns
Returns Ok(()) if the server shuts down gracefully, or an error
if the server fails to start or encounters a fatal error.
§Example
use elara_runtime::health::HealthChecker;
use elara_runtime::health_server::HealthServer;
use std::sync::Arc;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let checker = Arc::new(HealthChecker::new(Duration::from_secs(30)));
let server = HealthServer::with_default_config(checker);
// Run server (blocks until shutdown)
server.serve().await?;
Ok(())
}Sourcepub fn create_router(&self) -> Router
pub fn create_router(&self) -> Router
Creates the Axum router with all health check endpoints.
This method is public to allow testing and custom server configurations.
Auto Trait Implementations§
impl Freeze for HealthServer
impl !RefUnwindSafe for HealthServer
impl Send for HealthServer
impl Sync for HealthServer
impl Unpin for HealthServer
impl UnsafeUnpin for HealthServer
impl !UnwindSafe for HealthServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request