From 791b138504ab4be2a37d6ae38ca49e4c5e1633cc Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Wed, 12 Jun 2024 01:18:00 +0000 Subject: [PATCH] Comment in tonic::status::find_status_in_source_chain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comment mentions why we choose “Unavailable” for connection errors --- tonic/src/status.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tonic/src/status.rs b/tonic/src/status.rs index 0783bd8e2..968693f87 100644 --- a/tonic/src/status.rs +++ b/tonic/src/status.rs @@ -614,6 +614,11 @@ fn find_status_in_source_chain(err: &(dyn Error + 'static)) -> Option { return Some(Status::cancelled(timeout.to_string())); } + // If we are unable to connect to the server, map this to UNAVAILABLE. This is + // consistent with the behavior of a C++ gRPC client when the server is not running, and + // matches the spec of: + // > The service is currently unavailable. This is most likely a transient condition that + // > can be corrected if retried with a backoff. #[cfg(feature = "transport")] if let Some(connect) = err.downcast_ref::() { return Some(Status::unavailable(connect.to_string()));