Skip to content

feat(client/dispatch): try_poll_ready() methods #3892

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

Closed

Conversation

cratelyn
Copy link
Member

this change is motivated by aiming to use interfaces like hyper::client::conn::http2::SendRequest::try_send_request() or hyper::client::conn::http1::SendRequest::try_send_request() in the context of tower middleware; the Service<T> trait's signature is such that the same error type be returned from Service::poll_ready() and Service::call().

this means that services that might resolve to a recovered message may call try_poll_ready when polling for readiness.

this avoids making TrySendError<T> constructable externally, see #3883 as an alternate approach that was considered.

this change is motivated by aiming to use interfaces like
`hyper::client::conn::http2::SendRequest::try_send_request()` or
`hyper::client::conn::http1::SendRequest::try_send_request()` in the
context of tower middleware; the `Service<T>` trait's signature is such
that the same error type be returned from `Service::poll_ready()` and
`Service::call()`.

this means that services that might resolve to a recovered message may
call `try_poll_ready` when polling for readiness.

this avoids making `TrySendError<T>` constructable externally, see hyperium#3883
as an alternate approach that was considered.

Signed-off-by: katelyn martin <git@katelyn.world>
@cratelyn
Copy link
Member Author

ci is failing due to some #[cfg(feature = "httpX")] flags missing.

cratelyn added a commit to cratelyn/hyper that referenced this pull request Jul 29, 2025
this commit introduces a `std::error::Error` implementation for
`hyper::client::conn::TrySendError`.

this allows callers of
`hyper::client::conn::http2::SendRequest::try_send_request()` or
`hyper::client::conn::http1::SendRequest::try_send_request()` to box a
`TrySendError<T>` without discarding a potentially recovered message.

a `std::fmt::Display` implementation is added in this commit, because it
is a prerequisite for implementations of `std::error::Error`.

for some previous discussion on this topic, see "_other options_" here:
hyperium#3883 (comment).

Ref: hyperium#3883
Ref: hyperium#3892
Signed-off-by: katelyn martin <git@katelyn.world>
@cratelyn
Copy link
Member Author

closing this for now, in favor of #3922.

@cratelyn cratelyn closed this Jul 29, 2025
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.

1 participant