Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tonic): Move ConnectError type from transport #1828

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

FrankReh
Copy link
Contributor

@FrankReh FrankReh commented Jul 28, 2024

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 and connect_returns_err_via_call_after_connected)

FrankReh added 3 commits July 27, 2024 10:32
By moving the TimeoutExpired type from the transport module
to the the tonic engine proper, the type is made available to
other transport implementations and tonic can be built without
the "server" feature while still returning a Status indicating
the timeout.

Alternative transport implementations can use the type, now that it is
moved, when they want the tonic Status error handling to recognize the
error as having been triggered by a timeout in the transport logic. The
tonic Status error will have a code of Cancelled with a message of
"Timeout expired".

There is already a test for this:

    cargo test picks_server_timeout_if_thats_sorter

which worked the original way and contines to work; but now a new
transport implementation can get the same behavior.

Addresses hyperium#1825.
@FrankReh FrankReh marked this pull request as ready for review July 29, 2024 07:28
Copy link
Contributor

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @tottoto any thoughts?

@tottoto
Copy link
Collaborator

tottoto commented Aug 1, 2024

Looks good to me.

@djc djc added this pull request to the merge queue Aug 1, 2024
Merged via the queue into hyperium:master with commit e3f2965 Aug 1, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants