Add lazy_with_connector + Unix socket support#15
Merged
iainmcgin merged 2 commits intoanthropics:mainfrom Mar 26, 2026
Merged
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Adds Http2Connection::lazy_with_connector and connect_with_connector as the generic transport escape hatch (same pattern as tonic's Endpoint::connect_with_connector). Callers provide a tower::Service<Uri> that yields any hyper::rt::Read + Write stream; the library boxes it and runs the h2 handshake. lazy_unix / connect_unix are thin wrappers demonstrating the pattern — they build a service_fn closure that dials tokio::net::UnixStream. BoxedIo is un-gated from client-tls since the custom-connector path uses the same type erasure. The box allocation is once per connection establishment, not per request.
6f1b0f7 to
9290e30
Compare
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
- Mark the lazy_with_connector doctest as ignore (UnixStream doesn't compile on non-Unix targets) - Add #[cfg_attr(docsrs, doc(cfg(unix)))] to lazy_unix/connect_unix so docs.rs shows platform-availability badges - Add crate-level #![cfg_attr(docsrs, feature(doc_cfg))] to enable the doc_cfg machinery - Add construction and failure-path tests for lazy_with_connector, connect_with_connector, lazy_unix, connect_unix
iainmcgin
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Adds
Http2Connection::lazy_with_connectorandconnect_with_connectoras the generic transport escape hatch (same pattern as tonic'sEndpoint::connect_with_connector). Callers provide atower::Service<Uri>that yields anyhyper::rt::Read + Writestream; the library boxes it internally and runs the h2 handshake.lazy_unix/connect_unixare thin convenience wrappers demonstrating the pattern — they build aservice_fnclosure that dialstokio::net::UnixStream.BoxedIois un-gated fromclient-tlssince the custom-connector path uses the same type erasure. The box allocation is once per connection establishment, not per request.API
Example