-
Notifications
You must be signed in to change notification settings - Fork 184
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
Extract round-robin host selection from the NewRoundRobinLoadBalancer #2741
Conversation
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.
servicetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/RoundRobinSelector.java
Show resolved
Hide resolved
...cetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/NewRoundRobinLoadBalancer.java
Show resolved
Hide resolved
servicetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/HostSelector.java
Outdated
Show resolved
Hide resolved
servicetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/RoundRobinSelector.java
Outdated
Show resolved
Hide resolved
servicetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/HostSelector.java
Outdated
Show resolved
Hide resolved
servicetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/HostSelector.java
Outdated
Show resolved
Hide resolved
servicetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/RoundRobinSelector.java
Outdated
Show resolved
Hide resolved
* 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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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:
HostSelector
interface.RoundRobinSelector
.