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: make ConnectionPoolPolicy consistent #3134

Merged

Conversation

bryce-anderson
Copy link
Contributor

Motivation:

We typically have a 'ies' class for the static helper methods, but right now we stuff all that into ConnectionPoolPolicy. We also tried to hide all the details by making the ConnectionPoolPolicy a data carrier instead of having any behavior, but that makes some extra noise around conversions.

Modifications:

  • Make ConnectionPoolPolicy follow the pattern in LoadBalancingPolicy, in that it's a factory but the constructor and methods are package private to control proliferation.
  • Remove the internal time ConnetionPoolFactory which is now subsumed by ConnectionPoolPolicy.
  • Make ConnectionPoolPolicies to follow the pattern established patterns.

Result:

More consistent code.

Motivation:

We typically have a 'ies' class for the static helper methods, but
right now we stuff all that into ConnectionPoolPolicy. We also tried
to hide all the details by making the ConnectionPoolPolicy a data
carrier instead of having any behavior, but that makes some extra
noise around conversions.

Modifications:

- Make ConnectionPoolPolicy follow the pattern in LoadBalancingPolicy,
  in that it's a factory but the constructor and methods are package
  private to control proliferation.
- Remove the internal time ConnetionPoolFactory which is now subsumed
  by ConnectionPoolPolicy.
- Make ConnectionPoolPolicies to follow the pattern established
  patterns.

Result:

More consistent code.
this.linearSearchSpace = ensurePositive(linearSearchSpace, "linearSearchSpace");
}
}
abstract ConnectionSelector<C> buildConnectionSelector(String lbDescription);
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we are ready to open this up together with ConnectionSelector? If yes, we will be able to change from an abstract class to an interface (could be a follow up, no need to mix all in this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, and I thought about it as well. The same question applies to the LoadBalancingPolicy.

I'm torn: it does feel like it should be an interface but otoh this pattern lets us not commit to any specific API. Let's discuss it in a followup.

@bryce-anderson bryce-anderson merged commit 869c12a into apple:main Dec 11, 2024
11 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/ConnectionPoolPolicies branch December 11, 2024 03:07
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.

2 participants