Skip to content
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

Extract round-robin host selection from the NewRoundRobinLoadBalancer #2741

Conversation

bryce-anderson
Copy link
Contributor

Motivation:

We want to be able to swap out load balancer algorithms but right
now that is in-lined in the same file as the host set management.

Modifications:

  • Define the internal HostSelector interface.
  • Extract the host selection algorithm into it's own class
    RoundRobinSelector.

Motivation:

We want to be able to swap out load balancer algorithms but right
now that is in-lined in the same file as the host set management.

Modifications:

- Extract the host selection algorithm into it's own class
  RoundRobinSelector.
@bryce-anderson bryce-anderson marked this pull request as ready for review October 31, 2023 17:24
* This method will be called concurrently with other selectConnection calls and
* hostSetChanged calls and must be thread safe under those conditions.
*/
Single<C> selectConnection(Predicate<C> selector, @Nullable ContextMap context,
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering whether this needs to return a re-active primitive or a richer API that would rely less on extracting information from an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you thinking of something similar to the Scala Try?

It seems like we have three possible results: a synchronous connection, a synchronous failure, and an asynchronous connection which may fail. The asynchronous path makes it such that we must lift it to a Single at some point.

I'm going to merge this as it is for now and we can massage it later as it's deficiencies become more apparent with more examples.

@bryce-anderson bryce-anderson merged commit 65e006d into apple:main Nov 1, 2023
15 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/extract_host_selection_algorithm branch November 1, 2023 21:45
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