Skip to content

Allow selecting a backend per client - #53

Merged
bdbai merged 1 commit into
bdbai:mainfrom
cavivie:feature/client-backend-selection
Aug 31, 2026
Merged

bdbai merged 1 commit into
bdbai:mainfrom
cavivie:feature/client-backend-selection

Conversation

@cavivie

@cavivie cavivie commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Nyquest currently relies on one process-global backend. That works well for the preset path, but makes it difficult for an application to use different native transports or for a library or test to inject a backend without changing global state.

This adds custom_backend to ClientBuilder. A builder uses the registered global backend by default, while callers can explicitly provide a backend for an individual client. The resulting client remains type-erased, so the backend type does not propagate through application APIs.

The existing global registration and missing-backend panic behavior remain unchanged.

This implements the custom backend per client part of #1. It is also useful groundwork for per-client Android backend selection discussed in #52, but does not add a Cronet backend itself.

Tested with:

  • async-only and blocking-only client backend tests
  • cargo test -p nyquest --all-features
  • cargo clippy -p nyquest --all-targets --all-features -- -D warnings

@bdbai

bdbai commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Regarding custom backends this is what I have in mind: db820ca. wdyt?

The panic with no global backend configured is meant to highlight the incomplete setup to the end user as early as possible. I still suggest keeping it as is.

@cavivie

cavivie commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, this approach works for our use case. I've updated the PR to use the generic builder state and custom_backend(&backend), while keeping the existing global registration and missing-backend panic behavior unchanged. The tests still cover multiple clients using different backends without global registration.

@cavivie
cavivie force-pushed the feature/client-backend-selection branch from 550881b to bfe18f6 Compare August 31, 2026 03:00
@bdbai bdbai added enhancement New feature or request good first issue Good for newcomers labels Aug 31, 2026
@bdbai

bdbai commented Aug 31, 2026

Copy link
Copy Markdown
Owner

thanks!

@bdbai
bdbai merged commit 041ea6f into bdbai:main Aug 31, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants