From 0ea877c5d0de10b45768da80c658785835d625e6 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Sat, 12 Oct 2024 12:58:51 -0500 Subject: fix: preserve configured service order --- src/service.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/service.rs') diff --git a/src/service.rs b/src/service.rs index b10385a..9ca9fc6 100644 --- a/src/service.rs +++ b/src/service.rs @@ -46,11 +46,18 @@ pub fn default_interval() -> std::time::Duration { } #[derive(Debug, Clone, Deserialize)] -#[serde(untagged)] -pub enum ServiceConfig { +pub struct ServiceConfig { + pub name: String, + #[serde(flatten)] + pub kind: ServiceKind, +} + +#[derive(Debug, Clone, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum ServiceKind { Http(http::Http), Tcp(tcp::Tcp), - Command(command::Command), + Exec(command::Command), } #[derive(Debug, thiserror::Error)] @@ -63,14 +70,14 @@ pub enum ServiceError { Command(#[from] command::Error), } -impl IntoService for ServiceConfig { +impl IntoService for ServiceKind { type Error = ServiceError; fn into_service(self) -> impl Stream> + Send { match self { - ServiceConfig::Http(h) => h.into_service().map_err(ServiceError::from).boxed(), - ServiceConfig::Tcp(t) => t.into_service().map_err(ServiceError::from).boxed(), - ServiceConfig::Command(c) => c.into_service().map_err(ServiceError::from).boxed(), + ServiceKind::Http(h) => h.into_service().map_err(ServiceError::from).boxed(), + ServiceKind::Tcp(t) => t.into_service().map_err(ServiceError::from).boxed(), + ServiceKind::Exec(c) => c.into_service().map_err(ServiceError::from).boxed(), } } } -- cgit v1.2.3-70-g09d2