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: Some cleanups for DefaultHost #2779

Merged

Conversation

bryce-anderson
Copy link
Contributor

@bryce-anderson bryce-anderson commented Dec 12, 2023

Note: this is based on #2770 which I'd like to merge first.

Motivation:

DefaultHost has a bunch of state balled up in ConnState
and we end up doing a bunch of unchecked casts. This makes
it tough to read and tough for the compiler to do it's job.

It turns out that we also have some poor life-cycle
management going on so we can tidy that up as well.

Modifications:

  • Make ConnState an instance class and pull in the type arg C.
  • Make it's connection array a List. This is because it's
    not easy to make an array from generic types which is perhaps
    the reason we were using an Object[] in the first place.
  • Remove the Host.markClosed() method and instead just use
    the AsyncClosable close API's. This makes it so the onClose
    listeners all hear when the connection is closed, and not just
    due to expiration.

Motivation:

DefaultHost has a bunch of state balled up in ConnState
and we end up doing a bunch of unchecked casts. This makes
it tough to read and tough for the compiler to do it's job.

It turns out that we also have some poor life-cycle
management going on so we can tidy that up as well.

Modifications:

Make ConnState an instance class and pull in the type arg C.
Make it's connection array a List. This is because it's
not easy to make an array from generic types which is perhaps
the reason we were using an Object[] in the first place.
Remove the Host.markClosed() method and instead just use
the AsyncClosable close API's. This makes it so the onClose
listeners all hear when the connection is closed, and not just
due to expiration.
@bryce-anderson bryce-anderson force-pushed the bl_anderson/DefaultHostCleanups branch from 4f9cddd to 8b34b75 Compare December 13, 2023 17:07
@bryce-anderson bryce-anderson force-pushed the bl_anderson/DefaultHostCleanups branch from 8b34b75 to 2b84fe3 Compare December 13, 2023 17:11
@bryce-anderson bryce-anderson marked this pull request as ready for review December 18, 2023 16:16
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.

love the cleanup

@bryce-anderson bryce-anderson merged commit e3daaf3 into apple:main Dec 19, 2023
15 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/DefaultHostCleanups branch December 19, 2023 16:28
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