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

loadbalancer-experimental: add provider for enabling DefaultLoadBalancer #2900

Merged

Conversation

bryce-anderson
Copy link
Contributor

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.

@bryce-anderson bryce-anderson marked this pull request as ready for review April 23, 2024 16:40
@bryce-anderson bryce-anderson force-pushed the bl_anderson/experimental-lb-provider branch from 4fb8b35 to 3e52a30 Compare April 25, 2024 17:09
@bryce-anderson bryce-anderson requested a review from daschl April 25, 2024 17:10
@bryce-anderson bryce-anderson merged commit 53f9f35 into apple:main Apr 26, 2024
15 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/experimental-lb-provider branch April 26, 2024 17:20
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a 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")
Copy link
Member

@idelpivnitskiy idelpivnitskiy May 7, 2024

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);
Copy link
Member

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");
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

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

may be static

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.

4 participants