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: HostObserver shouldn't need a type param #2821

Merged

Conversation

bryce-anderson
Copy link
Contributor

@bryce-anderson bryce-anderson commented Feb 2, 2024

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
  • Modify the HealthChecker interfaces to take the HostObserver during construction of the associated HealthIndicator

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?
@bryce-anderson bryce-anderson marked this pull request as draft February 2, 2024 23:24
@bryce-anderson bryce-anderson marked this pull request as ready for review February 2, 2024 23:57
@bryce-anderson bryce-anderson requested a review from daschl February 6, 2024 00:21
Copy link
Contributor

@tkountis tkountis left a comment

Choose a reason for hiding this comment

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

good to go

@bryce-anderson bryce-anderson merged commit 05e07c4 into apple:main Feb 6, 2024
12 of 15 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/HostObserver_changes branch February 6, 2024 19:32
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.

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

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

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

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

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.

3 participants