From cd774827dd14f68d8405c45d2d9da30b3fab050e Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Sat, 28 Sep 2024 00:54:46 -0500 Subject: feat: refactor into pub-sub and impl SSE --- src/api.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/api.rs') diff --git a/src/api.rs b/src/api.rs index 8dfd2ca..1489c21 100644 --- a/src/api.rs +++ b/src/api.rs @@ -3,11 +3,11 @@ use std::collections::HashMap; use axum::{extract::State, response::IntoResponse, Json}; use serde::{Deserialize, Serialize}; -use crate::{service::Services, Status}; +use crate::{service::ServiceHandles, Status}; pub mod services; -pub fn router() -> axum::Router { +pub fn router() -> axum::Router { use axum::routing::get; axum::Router::new() @@ -37,11 +37,11 @@ impl IntoResponse for Health { } } -pub async fn healthcheck(State(services): State) -> Health { - let checks = match services.check().await { - Ok(c) => c, - Err(err) => return err.into(), - }; +pub async fn healthcheck(State(services): State) -> Health { + let checks = services + .iter() + .map(|(name, srv)| (name.clone(), srv.status())) + .collect::>(); let status = match checks .values() -- cgit v1.2.3-70-g09d2