feat: introduce fetch_hyper#437
Conversation
Adds a new fetch_hyper crate that provides a hyper-based HTTP client transport implementing the http_extensions handler interface. Highlights: - HyperTransportBuilder for assembling a transport from a user-supplied connector, spawner, clock, TLS backend, and body builder, with hooks to configure the underlying hyper client. - Connection layer with a client connector, hyper connector adapter, tracked stream wrapper, and hyper-based request handler. - Pluggable TLS backend with a rustls-based connector. - Configurable options, recoverability classification, error labels, and telemetry surface for observability. - Test support module and a smoke test exercising the end-to-end transport. Also extends templated_uri with small base_uri/origin helpers required by the transport.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #437 +/- ##
========================================
Coverage 100.0% 100.0%
========================================
Files 286 299 +13
Lines 22978 23562 +584
========================================
+ Hits 22978 23562 +584 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new internal crate, fetch_hyper, to host the Hyper-based transport implementation and related utilities while keeping these APIs as an implementation detail (not part of the public surface of higher-level fetch/SDK crates). It also extends templated_uri with explicit vs effective port handling to support transport/telemetry needs.
Changes:
- Added new
crates/fetch_hypercrate with transport builder, connection plumbing, TLS backend selection, telemetry helpers, and extensive unit/integration tests + snapshots. - Updated
templated_urito distinguish explicit ports (port()) from scheme-inferred defaults (effective_port()), with tests/docs updates. - Wired the new crate into the workspace (root
Cargo.tomldeps, root README/changelog indices, lockfile updates).
Reviewed changes
Copilot reviewed 36 out of 37 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds fetch_hyper to the workspace crate list. |
| crates/templated_uri/src/origin.rs | Adds Origin::effective_port() and clarifies port() semantics + tests. |
| crates/templated_uri/src/base_uri.rs | Updates BaseUri::port() semantics and adds effective_port() + tests/docs. |
| crates/fetch_hyper/tests/smoke.rs | Adds wiremock-based end-to-end smoke coverage for the transport. |
| crates/fetch_hyper/src/tls/mod.rs | Introduces TlsBackend public enum and conversions + tests. |
| crates/fetch_hyper/src/tls/connector.rs | Adds internal TLS connector dispatch for rustls/native-tls. |
| crates/fetch_hyper/src/timer.rs | Implements a tick::Clock → hyper::rt::Timer adapter + tests. |
| crates/fetch_hyper/src/testing.rs | Adds in-process fakes/helpers for transport testing. |
| crates/fetch_hyper/src/telemetry.rs | Adds ConnectionInfo response extension and OTel attribute helpers + snapshots/tests. |
| crates/fetch_hyper/src/snapshots/fetch_hyper__telemetry__tests__create_connection_failure_attributes_includes_error_type.snap | Snapshot for failure connection attributes. |
| crates/fetch_hyper/src/snapshots/fetch_hyper__telemetry__tests__create_connection_attributes_emits_expected_keys.snap | Snapshot for success connection attributes. |
| crates/fetch_hyper/src/snapshots/fetch_hyper__options__tests__debug_renders_unlimited.snap | Snapshot for ConnectionLifetime debug output (Unlimited). |
| crates/fetch_hyper/src/snapshots/fetch_hyper__options__tests__debug_renders_per_connection_without_closure_fmt_panic.snap | Snapshot for ConnectionLifetime debug output (PerConnection). |
| crates/fetch_hyper/src/snapshots/fetch_hyper__options__tests__debug_renders_fixed.snap | Snapshot for ConnectionLifetime debug output (Fixed). |
| crates/fetch_hyper/src/snapshots/fetch_hyper__builder__tests__defaults.snap | Snapshot for builder default configuration. |
| crates/fetch_hyper/src/snapshots/fetch_hyper__builder__tests__configured.snap | Snapshot for configured builder state. |
| crates/fetch_hyper/src/recoverability.rs | Adds recoverability detection over error chains + tests. |
| crates/fetch_hyper/src/options.rs | Adds RequestFilter and ConnectionLifetime configuration types + tests. |
| crates/fetch_hyper/src/lib.rs | Declares crate modules and public exports; documents internal-only nature. |
| crates/fetch_hyper/src/error_labels.rs | Adds centralized error label constants and label collection logic + tests. |
| crates/fetch_hyper/src/connection/tracked_stream.rs | Adds connection lifecycle tracking stream wrapper with metrics/logs + tests. |
| crates/fetch_hyper/src/connection/snapshots/fetch_hyper__connection__client_connector__tests__verify_protocol_version_rejects_unsupported.snap | Snapshot for unsupported negotiated protocol error message. |
| crates/fetch_hyper/src/connection/mod.rs | Declares connection submodules and re-exports. |
| crates/fetch_hyper/src/connection/io.rs | Defines HyperIo trait alias and Box<dyn HyperIo> connection impl + tests. |
| crates/fetch_hyper/src/connection/hyper_handler.rs | Implements internal hyper-util client handler and poisoning logic + tests. |
| crates/fetch_hyper/src/connection/hyper_connector_adapter.rs | Adapts layered connector to tower::Service<Uri> for hyper-util + tests. |
| crates/fetch_hyper/src/connection/connect.rs | Defines the public Connect trait alias. |
| crates/fetch_hyper/src/connection/client_connector.rs | Implements connect-timeout, protocol verification, and telemetry around connects + tests. |
| crates/fetch_hyper/src/builder.rs | Adds HyperTransportBuilder and type-erased HyperTransport wrapper + tests/snapshots. |
| crates/fetch_hyper/README.md | Adds crate README (doc2readme-style output). |
| crates/fetch_hyper/logo.png | Adds crate logo via Git LFS. |
| crates/fetch_hyper/favicon.ico | Adds crate favicon via Git LFS. |
| crates/fetch_hyper/CHANGELOG.md | Adds initial changelog file. |
| crates/fetch_hyper/Cargo.toml | Adds crate manifest, features, deps, and test configuration. |
| CHANGELOG.md | Adds fetch_hyper to root changelog index. |
| Cargo.toml | Adds fetch_hyper workspace dependency and new workspace deps (hyper TLS/rustls/semconv/wiremock). |
| Cargo.lock | Locks new dependency graph introduced by fetch_hyper and TLS/test deps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use BaseUri::effective_port() in tracing events so default ports for http/https are included. - Omit server.port metric attribute when effective_port() is None instead of recording a misleading port 0. - Update testing module docs to reflect that it is crate-internal only. - Drop unused optional �ytes dependency; testing fakes already rely on the dev-dependency. - Remove redundant frozen-clock is_expired test whose name contradicted its assertion; the ClockControl-based test already covers the case. - Make clone_preserves_variant actually exercise Clone for both TlsBackend variants. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 35 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
crates/fetch_hyper/CHANGELOG.md:2
crates/fetch_hyperchangelog is currently just a header. Other crates in this workspace include at least an## Unreleasedsection or an initial## [0.1.0]entry; having an empty changelog makes release tooling and changelog navigation less useful. Consider adding an## Unreleasedsection (and/or an initial## [0.1.0]entry) consistent with the rest of the repo’s changelogs.
# Changelog
Extracting hyper-related APIs into separate crate. These APIs should be treated only as an internal implementation detail of hyper transport and will never be used directly nor exposed publicly from fetch.
Public APIs are kept to a minimum: