Skip to content

feat: Allow providing custom connector to balanced channels by exposing Channel::balance #2197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Suficio
Copy link
Contributor

@Suficio Suficio commented Mar 3, 2025

Motivation

I have a requirement to balance client gRPC requests via different connectors.

There is currently no API to construct a balanced Channel using a custom connector (it is possible to create a Channel with a custom connector using Endpoint::connect_with_connector_lazy).

Solution

There is currently an internal constructor Channel::balance with the following signature:

pub(crate) fn balance<D>(discover: D, ..) -> Self
where
    D: Discover<Service = Connection>,
    ...

Since Connection is a private type this PR modifies the signature to:

pub fn balance<D, C>(discover: D, ..) -> Self
where
    D: Discover<Service = (C, Endpoint)>,
    C: Service<Uri>,
    ...

This signature supports all internal uses of Channel::balance while allowing maximal flexibility for advanced use cases.

@Suficio Suficio changed the title Allow providing custom connector to balanced channels by exposing Channel::balance feat: Allow providing custom connector to balanced channels by exposing Channel::balance Mar 3, 2025
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