♻️ refactor: use `tokio::time::timeout`

main
_ 2021-04-27 20:15:21 -05:00
parent a661ce02ea
commit 33d07c45a8
1 changed files with 7 additions and 8 deletions

View File

@ -144,15 +144,14 @@ async fn handle_http_request (
state.park_client (server_name, req, &req_id).await; state.park_client (server_name, req, &req_id).await;
let timeout = tokio::time::sleep (std::time::Duration::from_secs (30)); let received = match tokio::time::timeout (Duration::from_secs (30), rx).await
{
let received = tokio::select! { Ok (x) => x,
val = rx => val, Err (_) => {
() = timeout => {
debug! ("Timed out request {}", req_id); debug! ("Timed out request {}", req_id);
return error_reply (StatusCode::GATEWAY_TIMEOUT, "Remote server never responded") return error_reply (StatusCode::GATEWAY_TIMEOUT, "Remote server never responded");
}, }
}; };
// UKAUFFY4 (Receive half) // UKAUFFY4 (Receive half)
match received { match received {