-
Notifications
You must be signed in to change notification settings - Fork 181
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
loadbalancer-experimental: add LB observer method for when the host set changes #3003
loadbalancer-experimental: add LB observer method for when the host set changes #3003
Conversation
…et changes Motivation: It can be valuable to know what the current host set is but we don't have a way to directly observer that right now. Modifications: Add a method to the LoadBalancerObserver that can capture when the host set changes and use it in DefaultLoadBalancer.
75eed92
to
bf3d1b9
Compare
...ider/src/main/java/io/servicetalk/loadbalancer/experimental/DefaultLoadBalancerObserver.java
Outdated
Show resolved
Hide resolved
...loadbalancer-experimental/src/main/java/io/servicetalk/loadbalancer/DefaultLoadBalancer.java
Outdated
Show resolved
Hide resolved
...loadbalancer-experimental/src/main/java/io/servicetalk/loadbalancer/DefaultLoadBalancer.java
Show resolved
Hide resolved
...ider/src/main/java/io/servicetalk/loadbalancer/experimental/DefaultLoadBalancerObserver.java
Outdated
Show resolved
Hide resolved
this.hostSelector = hostSelector.rebuildWithHosts(priorityStrategy.prioritize(usedHosts)); | ||
nextHosts = priorityStrategy.prioritize(nextHosts); | ||
this.hostSelector = hostSelector.rebuildWithHosts(nextHosts); | ||
loadBalancerObserver.onHostSetChanged(Collections.unmodifiableCollection(nextHosts)); |
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.
After the 2nd look: priorityStrategy
returns a List
. Why does the observer provide a Collection
? Just to align with SD discovery publisher contract? Will List
be beneficial to signal Host priorities to users of LB-observer?
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.
We talked offline and the static type of Collection
is fine and I've used the unmodifiableList
method to make the dynamic type more helpful.
Motivation:
It can be valuable to know what the current host set is but we don't have a way to directly observer that right now.
Modifications:
Add a method to the LoadBalancerObserver that can capture when the host set changes and use it in DefaultLoadBalancer.