Skip to content

feat: minimize default features and complete EventListener coverage - #76

Merged
fannnzhang merged 2 commits into
mainfrom
feature/min-features-and-event-lifecycle
Sep 7, 2026
Merged

feat: minimize default features and complete EventListener coverage#76
fannnzhang merged 2 commits into
mainfrom
feature/min-features-and-event-lifecycle

Conversation

@fannnzhang

Copy link
Copy Markdown
Contributor

Summary

Mobile-friendly Cargo features plus OkHttp-aligned call observability, including the four P2s from the local review.

Features and dependency pins

  • Workspace pins now disable unused default features (tokio/full, hyper/full, tower/timeout, rustls logging, extra futures-util macros).
  • Production crates request only the Tokio (rt/net/time/io-util/sync) and Hyper (client/http1/http2) features they use.
  • Compression splits into independently selectable gzip / deflate / brotli / zstd. compression remains the default umbrella. compression-core is the internal module gate; enabling it with no codec compiles and injects no Accept-Encoding.
  • Built-in Jar moves behind the cookies feature (still default-on). Custom CookieJar implementations do not need it. json now also gates logger pretty-print.

EventListener lifecycle

  • EventListenerFactory::create runs at Client::new_call / Call::try_clone, so cancel-before-execute and dispatcher events share a listener.
  • New callbacks (all defaulted): dispatcher queue, proxy select, tls_handshake, request/response body start, request_failed, response_failed, canceled, retry_decision, follow_up_decision, cache hit/miss/conditional/satisfaction.
  • Public types: ProxyEvent, TlsHandshake.

Body-event correctness (review P2s)

  • Present zero-length bodies (explicit_empty, from_static(b"")) emit request_body_start / request_body_end 0 at Hyper handoff instead of being skipped.
  • Try-send failures are classified from per-attempt CallContext flags, not Hyper TrySendError commitment, so upload errors do not also emit response_failed.
  • response_body_start waits for first data (or close without a prior read), matching OkHttp 4.3 / the trait docs.

Compatibility

  • Default feature users keep TLS, all codecs, and cookies.
  • default-features = false dependents that used Jar must now enable cookies, and must declare any extra Tokio/Hyper features their own crate needs.

Test plan

  • cargo check -p openwire --no-default-features --features compression-core --lib
  • cargo check -p openwire --no-default-features --features gzip --lib
  • cargo clippy -p openwire-core -p openwire --lib -- -D warnings
  • cargo test -p openwire-core --lib request_exchange_observation
  • cargo test -p openwire --lib compression::tests
  • Integration coverage for empty present bodies, upload request_failed, absent-body response_failed, delayed response_body_start, plus existing body/dispatcher/pool event tests
  • Full cargo test --workspace --all-features not run locally (disk ~2.5Gi free)

Make the workspace mobile-friendly and align call observability with OkHttp:

- Pin workspace deps with default-features = false and request only the
  Tokio, Hyper, tower, and rustls features production crates actually use.
- Split compression into gzip/deflate/brotli/zstd, with compression-core as
  the internal gate. Zero-codec builds compile and inject no Accept-Encoding.
- Gate the built-in Jar behind the cookies feature (enabled by default).
- Create EventListener at Call construction so cancel-before-execute and
  dispatcher events share a listener.
- Add dispatcher, proxy, TLS handshake, request/response body, cancel,
  retry_decision, follow_up_decision, and cache callbacks.
- Emit present empty-body events at Hyper handoff, classify try-send
  failures independently of request commitment, and fire response_body_start
  on first data or close-without-read.
Clippy 1.98 result_large_err fails because WebSocketError inlined WireError
and exceeded 128 bytes. Box the IO payload so Result<_, WebSocketError>
stays small without changing the public callback surface.
@fannnzhang
fannnzhang merged commit becd9ae into main Sep 7, 2026
7 checks passed
@fannnzhang
fannnzhang deleted the feature/min-features-and-event-lifecycle branch September 7, 2026 09:03
@fannnzhang fannnzhang mentioned this pull request Sep 7, 2026
3 tasks
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