-
Notifications
You must be signed in to change notification settings - Fork 182
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 provider for enabling DefaultLoadBalancer #2900
loadbalancer-experimental: add provider for enabling DefaultLoadBalancer #2900
Conversation
…ncer Motivation: We want to make it easy for people to enable the DefaultLoadBalancer. Modifications: - add a new package that includes a provider that can be used
.../src/main/java/io/servicetalk/loadbalancer/experimental/DefaultHttpLoadBalancerProvider.java
Show resolved
Hide resolved
.../src/main/java/io/servicetalk/loadbalancer/experimental/DefaultHttpLoadBalancerProvider.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/servicetalk/loadbalancer/experimental/DefaultLoadBalancerProviderConfig.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/servicetalk/loadbalancer/experimental/DefaultLoadBalancerProviderConfig.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/servicetalk/loadbalancer/experimental/DefaultLoadBalancerProviderConfig.java
Outdated
Show resolved
Hide resolved
4fb8b35
to
3e52a30
Compare
...ider/src/main/java/io/servicetalk/loadbalancer/experimental/DefaultLoadBalancerObserver.java
Outdated
Show resolved
Hide resolved
...ider/src/main/java/io/servicetalk/loadbalancer/experimental/DefaultLoadBalancerObserver.java
Show resolved
Hide resolved
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.
Late comments, overall LGTM:
testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version") | ||
|
||
api project(":servicetalk-client-api") | ||
api project(":servicetalk-concurrent-api") |
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.
The only api
dependency should be :servicetalk-http-api
. Others are transitive dependencies through http-api
. If you'd like, you can keep an explicit definition of :servicetalk-client-api
as well, but there is no dependency on :servicetalk-concurrent-api
.
HttpLoadBalancerFactory<R> loadBalancerFactory = DefaultHttpLoadBalancerFactory.Builder.<R>from( | ||
defaultLoadBalancer(serviceName)).build(); | ||
builder = builder.loadBalancerFactory(loadBalancerFactory); | ||
return new LoadBalancerIgnoringBuilder(builder, serviceName); |
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.
Missing <>
after class name
private final String clientName; | ||
|
||
DefaultLoadBalancerObserver(final String clientName) { | ||
this.clientName = requireNonNull(clientName, "clientName"); |
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.
Would be ideal if the DefaultLoadBalancer
could propagate its lbDescription
. The main motivation is being able to distinguish one instance of a client to "servicetalk.io" (or any "serviceFoo") from another instance to exact same address. Additionally, it will help to correlate observer events with DefaultLoadBalancer
logs.
} | ||
|
||
<U, C extends LoadBalancedConnection> LoadBalancingPolicy<U, C> getLoadBalancingPolicy() { | ||
if (lbPolicy == lbPolicy.P2C) { |
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.
nit: lbPolicy.P2C
-> LbPolicy.P2C
} | ||
} | ||
|
||
private Set<String> getClientsEnabledFor(String propertyValue) { |
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.
may be static
Motivation:
We want to make it easy for users to enable DefaultLoadBalancer
for specific clients and then manipulate it's behavior via system
properties so they don't require rebuilding apps to test.
Modifications:
Add a new package that includes a
SingleAddressHttpClientBuilderProvider
which enables users to enable DefaultLoadBalancer for clients
based on the address used, or all clients if desired.