-
Notifications
You must be signed in to change notification settings - Fork 186
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: HostObserver shouldn't need a type param #2821
loadbalancer-experimental: HostObserver shouldn't need a type param #2821
Conversation
Motivation: The current HostObserver API requires one to pass in the ResolvedAddress on each callback. This means that every place we want to observer events also needs to know the address which can be a pain. Modifications: - Drop the type parameter from HostObserver - Make LoadBalancerObserver take the address as a parameter of the `hostObserver(..)` method. - Propagate those changes all over the place Result: What is the result of this change?
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.
good to go
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.
Overall LGTM, minor comments:
* @param cause the most recent cause of the transition. | ||
*/ | ||
void onHostMarkedUnhealthy(ResolvedAddress address, @Nullable Throwable cause); | ||
void onHostMarkedUnhealthy(@Nullable Throwable cause); |
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.
Seems like we always have the cause, should we remove @Nullable
annotation?
@@ -135,13 +135,13 @@ public LoadBalancerFactory<ResolvedAddress, C> build() { | |||
} | |||
final LoadBalancerObserver<ResolvedAddress> loadBalancerObserver = this.loadBalancerObserver != null ? | |||
this.loadBalancerObserver : NoopLoadBalancerObserver.instance(); | |||
Supplier<HealthChecker<ResolvedAddress>> healthCheckerSupplier; | |||
Function<String, HealthChecker<ResolvedAddress>> healthCheckerSupplier; |
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.
healthCheckerSupplier -> healthCheckerFactory?
Also, consider marking it as final
@Nullable | ||
private final HealthCheckConfig healthCheckConfig; | ||
|
||
DefaultLoadBalancerFactory(final String id, final LoadBalancingPolicy<ResolvedAddress, C> loadBalancingPolicy, | ||
final int linearSearchSpace, final HealthCheckConfig healthCheckConfig, | ||
final LoadBalancerObserver<ResolvedAddress> loadBalancerObserver, | ||
final Supplier<HealthChecker<ResolvedAddress>> healthCheckerFactory) { | ||
final Function<String, HealthChecker<ResolvedAddress>> healthCheckerFactory) { |
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.
This arg should have @Nullable
annotation
Motivation:
The current HostObserver API requires one to pass in the ResolvedAddress on each callback. This means that every place we want to observer events also needs to know the address which can be a pain.
Modifications:
HostObserver
LoadBalancerObserver
take the address as a parameter of thehostObserver(..)
methodHealthChecker
interfaces to take theHostObserver
during construction of the associatedHealthIndicator