From 33025e3e7b6427ccc2beae8df2ef64c4a959b4d2 Mon Sep 17 00:00:00 2001 From: mario Date: Mon, 11 Dec 2023 21:44:53 +0200 Subject: [PATCH] reflect updating a server's health check period Signed-off-by: mario --- src/balancer.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/balancer.rs b/src/balancer.rs index eb72dd3..d2c583e 100644 --- a/src/balancer.rs +++ b/src/balancer.rs @@ -227,10 +227,24 @@ impl Balancer { } APIRequest::UpdateServer(server) => { let url = server.url.clone(); + let period = server.health_check_period; self.update_server(server) .map_err(|e| APIResponse::Error(StatusCode::BAD_REQUEST, e.to_string()))?; log::info!("server {:?} was updated", url); + health_check_request_tx + .send(HealthCheckRequest::Stop(url.clone())) + .await + .map_err(|e| { + APIResponse::Error(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()) + })?; + + health_check_request_tx + .send(HealthCheckRequest::Start(url, period)) + .await + .map_err(|e| { + APIResponse::Error(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()) + })?; } }