diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-09-28 00:54:46 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-09-28 00:58:45 -0500 |
commit | cd774827dd14f68d8405c45d2d9da30b3fab050e (patch) | |
tree | a24e1cabb99170caa25edff53fc978111a1c9dd4 /src/api.rs | |
parent | 04c7f7609e5bc3fadf95c53b37a9e6e12c4e539c (diff) |
feat: refactor into pub-sub and impl SSE
Diffstat (limited to 'src/api.rs')
-rw-r--r-- | src/api.rs | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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<Services> { +pub fn router() -> axum::Router<ServiceHandles> { use axum::routing::get; axum::Router::new() @@ -37,11 +37,11 @@ impl IntoResponse for Health { } } -pub async fn healthcheck(State(services): State<Services>) -> Health { - let checks = match services.check().await { - Ok(c) => c, - Err(err) => return err.into(), - }; +pub async fn healthcheck(State(services): State<ServiceHandles>) -> Health { + let checks = services + .iter() + .map(|(name, srv)| (name.clone(), srv.status())) + .collect::<HashMap<String, Status>>(); let status = match checks .values() |