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

feat: make pub Channel fns that allow creating it from a custom connector #2015

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shikhar
Copy link
Contributor

@shikhar shikhar commented Oct 18, 2024

The connector is required to be a Service that accepts a http::Uri and returns a connection implementing hyper's IO traits, which is a very reasonable requirement that can be fulfilled by advanced users that need to customize any mechanics that don't fit into the paved path for HTTP and HTTPS with tonic.

One such requirement is customizing rustls::ClientConfig, which has come up for a number of users. They have been pointed in the direction of a custom connector, but the APIs on Endpoint are not always suitable:

Endpoint::connect_(lazy_)with_connector always wraps the provided connector with transport::channel::service::Connector. This wrapper raises an error HttpsUriWithoutTlsSupport if (the scheme is https:// + the tls feature is enabled + and Endpoint::tls_config() was not used) ref. This is a good safety feature in general, but not if the wrapped connector is taking care of TLS.

As a side bonus, transport::channel::service::io::BoxedIo can be avoided.

…nector

The connector is required to be a `Service` that accepts a `http::Uri` and
returns a connection implementing hyper's IO traits, which is a very reasonable
requirement that can be fulfilled by advanced users that need to customize any
mechanics that don't fit into the paved path for HTTP and HTTPS with tonic.

One such requirement is customizing `rustls::ClientConfig`, which has come up
for a number of users. They have been pointed in the direction of a custom
connector, but the APIs on `Endpoint` are not always suitable:

`Enedpoint::connect_(lazy_)with_connector` always wraps the provided connector
with `transport::channel::service::Connector`. This wrapper validates if the
scheme is HTTPS, the TLS feature is enabled, and TLS was not configured on the
endpoint, and raises an error `HttpsUriWithoutTlsSupport` in this situation.
This is a good safety feature in general, but not if the wrapped connector is
taking care of TLS.

As a side bonus, `tonic::transport::channel::service::io::BoxedIo` can be
avoided.
Copy link
Collaborator

@tottoto tottoto left a comment

Choose a reason for hiding this comment

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

Sounds reasonable to me.

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.

2 participants