summaryrefslogtreecommitdiffstats
path: root/src/service.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-10-12 12:58:51 -0500
committerToby Vincent <tobyv@tobyvin.dev>2024-10-12 12:58:51 -0500
commit0ea877c5d0de10b45768da80c658785835d625e6 (patch)
tree38a5c6209e2063753f43e037e93a7e381bde16dd /src/service.rs
parent859fd855e1a819280931ffbb6ae98098b2774269 (diff)
fix: preserve configured service order
Diffstat (limited to 'src/service.rs')
-rw-r--r--src/service.rs21
1 files changed, 14 insertions, 7 deletions
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<Item = Result<(), Self::Error>> + 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(),
}
}
}