summaryrefslogtreecommitdiffstats
path: root/src/service.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/service.rs')
-rw-r--r--src/service.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/service.rs b/src/service.rs
index b67ba51..74ecb1d 100644
--- a/src/service.rs
+++ b/src/service.rs
@@ -13,6 +13,21 @@ pub trait IntoService {
) -> impl std::future::Future<Output = ()>;
}
+impl IntoService for () {
+ async fn into_service(self, tx: tokio::sync::watch::Sender<Status>) {
+ let mut interval = tokio::time::interval(std::time::Duration::from_secs(3));
+ let mut status = Status::Ok;
+
+ loop {
+ interval.tick().await;
+ status = match tx.send_replace(status) {
+ Status::Ok => Status::Error(Some("Test status is in the error state".into())),
+ Status::Error(_) => Status::Ok,
+ };
+ }
+ }
+}
+
pub fn default_interval() -> std::time::Duration {
std::time::Duration::from_secs(5)
}
@@ -31,11 +46,13 @@ pub enum ServiceKind {
Http(http::Http),
Tcp(tcp::Tcp),
Exec(command::Command),
+ Test(()),
}
impl IntoService for ServiceKind {
async fn into_service(self, tx: tokio::sync::watch::Sender<Status>) {
match self {
+ ServiceKind::Test(()) => ().into_service(tx).await,
ServiceKind::Http(h) => h.into_service(tx).await,
ServiceKind::Tcp(t) => t.into_service(tx).await,
ServiceKind::Exec(c) => c.into_service(tx).await,