chore(tonic): Move ConnectError type from transport #1828
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Move the ConnectError type from transport to tonic.
Motivation
Making
ConnectError
a tonic type allows the tonic Status to convert a transport generated connection error into a Status::code() of Status::unavailable. As the comment in status.rs already says, this is consistent with the behavior of a C++ gRPC client when the server is not running, and matches the spec.The only other error that results in a Status::unavailable is a timeout error when the crate is built with its 'transport' module, allowing it to recognize when an error is a hyper timeout error. But a possible loosening of that relationship is not being addressed here.
Solution
Move the type from the transport module, where it can only be used by the Status code when tonic is compiled with its own transport, to the status code in tonic itself, so the built in transport can use it and proprietary transports can use it.
There are already two tests that look for this Status::unavailable result. They passed before and they pass with this change as well. (
connect_lazy_reconnects_after_first_failure
andconnect_returns_err_via_call_after_connected
)