From 5878be6216627f413c81bdd7bc43aad59ee9295d Mon Sep 17 00:00:00 2001 From: Avril Date: Tue, 19 Jan 2021 00:35:35 +0000 Subject: [PATCH] uhh, supervisor task term handling i think --- src/state/service/supervisor/mod.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/state/service/supervisor/mod.rs b/src/state/service/supervisor/mod.rs index 3010cc4..af4a56e 100644 --- a/src/state/service/supervisor/mod.rs +++ b/src/state/service/supervisor/mod.rs @@ -158,7 +158,7 @@ async fn service_fn(SupervisorTaskState {shared, mut recv, mut shutdown}: Superv // The command stream to dispatch to the worker tasks let command_dispatch = async { while let Some(req) = recv.recv().await { - //TODO: Dispatch + todo!("Dispatch to child(s)"); } TerminationKind::Graceful }; @@ -170,12 +170,12 @@ async fn service_fn(SupervisorTaskState {shared, mut recv, mut shutdown}: Superv { use SupervisorControl::*; match value { - Initialise => (), + Initialise => info!("Initialised"), Signal(None) => return TerminationKind::SignalHup, Signal(Some(to)) => return TerminationKind::SignalTimeout(to), Drop => return TerminationKind::Immediate, - Restart => (), - TaskLimit(_limit) => (), + Restart => todo!("not implemented"), + TaskLimit(_limit) => todo!("not implemented"), } } TerminationKind::Graceful @@ -187,18 +187,15 @@ async fn service_fn(SupervisorTaskState {shared, mut recv, mut shutdown}: Superv sd_kind = &mut signal_stream => { // We received a signal - return Err(ServiceTerminationError::Signal(sd_kind)); + Err(ServiceTerminationError::Signal(sd_kind)) } disp_end = &mut command_dispatch => { // The command dispatch exited first, the logical error is `Graceful`. But it's not really an error, so... - - //TODO: Anything here? + disp_end.into() } } // } - - - Ok(()) + } /// The mannor in which the supervisor exited. #[derive(Debug)] @@ -254,6 +251,15 @@ pub enum ServiceTerminationError Interest, } +impl From for Result<(), ServiceTerminationError> +{ + fn from(from: TerminationKind) -> Self + { + ServiceTerminationError::Signal(from).into_own_result() + } +} + + impl ServiceTerminationError { fn into_own_result(self) -> Result<(), Self>