Skip to content

Commit

Permalink
Comment in tonic::status::find_status_in_source_chain
Browse files Browse the repository at this point in the history
Comment mentions why we choose “Unavailable” for connection errors
  • Loading branch information
alexrudy committed Jun 12, 2024
1 parent afc8355 commit e167697
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tonic/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,11 @@ fn find_status_in_source_chain(err: &(dyn Error + 'static)) -> Option<Status> {
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::<crate::transport::ConnectError>() {
return Some(Status::unavailable(connect.to_string()));
Expand Down

0 comments on commit e167697

Please sign in to comment.