Skip to content

Add async single-flight proxy resolution#8

Merged
chrmarti merged 1 commit into
mainfrom
chrmarti/async-singleflight
Jul 14, 2026
Merged

Add async single-flight proxy resolution#8
chrmarti merged 1 commit into
mainfrom
chrmarti/async-singleflight

Conversation

@chrmarti

Copy link
Copy Markdown
Contributor

Summary

  • add a Tokio-gated resolve_proxy_async API backed by one lazy dedicated resolver thread
  • coalesce identical URL/config-generation lookups so concurrent callers await one result without occupying blocking threads
  • queue distinct targets through a bounded channel, with panic and cancellation-safe in-flight cleanup
  • retain the existing synchronous API for runtime-agnostic and callback consumers

Validation

  • cargo test
  • cargo test --features tokio
  • cargo clippy --all-targets --features tokio -- -D warnings
  • cargo fmt --all -- --check
  • concurrency test: 32 simultaneous same-URL calls on a current-thread Tokio runtime start exactly one blocking resolution

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a Tokio-gated asynchronous proxy-resolution API that avoids blocking async runtime workers by funneling resolution through a lazily created dedicated background thread, while coalescing identical concurrent lookups (“single-flight”) and bounding queued work.

Changes:

  • Add ProxyResolver::resolve_proxy_async (Tokio feature) implemented via a per-resolver background worker plus in-flight coalescing keyed by URL + config generation.
  • Expose a crate-level resolve_proxy_async convenience wrapper for the global resolver.
  • Update docs and add a Tokio concurrency test validating identical-call coalescing.
Show a summary per file
File Description
src/types.rs Makes Error clonable to support sharing async results through channels.
src/resolver.rs Implements the async worker thread, in-flight coalescing, bounded queueing, and adds a Tokio test.
src/lib.rs Exposes a new Tokio-gated resolve_proxy_async wrapper on the global resolver.
README.md Documents the new async API and recommended usage under the tokio feature.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 4
  • Review effort level: Low

Comment thread src/resolver.rs Outdated
Comment thread src/resolver.rs
Comment thread src/lib.rs Outdated
Comment thread README.md Outdated
@chrmarti chrmarti force-pushed the chrmarti/async-singleflight branch from cc68100 to 935c0d0 Compare July 14, 2026 10:17
@chrmarti chrmarti merged commit 4e2bfc6 into main Jul 14, 2026
26 checks passed
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.

3 participants