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

refactor: augment poolRouter interface (and simpleRouter) #7508

Merged
merged 5 commits into from
Mar 2, 2023

Conversation

shollyman
Copy link
Contributor

@shollyman shollyman commented Mar 2, 2023

This PR extends the poolRouter interface to include more lifecycle signalling:

  • when a router takes control of it's connectionPool
  • when a connection pool is going away
  • when a writer is attached to the pool
  • when a writer is detached from the pool

The core problem this addresses is proper shutdown between the components. We need to propagate this information to shutdown cleanly so that connections can go away in response to their writers.

This PR also augments our existing simpleRouter to adhere to the enlarged interface contract. The pool attach/detach events are left unimplemented as we need to plumb this in when we wire up the abstractions end to end, which will happen when we rewire the internals to use the new abstractions.

A test has been added to assert simpleRouter state when writers are attached and removed.

Towards: #7103

This PR extends the poolRouter interface to allow writers to be
registered and removed, and augments the existing simpleRouter to
support the contract.

PR adds a basic test of the router.

A future refactor (when we wire up the new abstractions) will hook
up the functionality properly.

Towards: googleapis#7103
@shollyman shollyman requested review from alvarowolfx and a team March 2, 2023 03:19
@shollyman shollyman requested a review from a team as a code owner March 2, 2023 03:19
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Mar 2, 2023
Copy link
Contributor

@alvarowolfx alvarowolfx left a comment

Choose a reason for hiding this comment

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

Looks good to me, I added a minor comment on the addWriter. Not sure if there are cases where the router is not going to be set.

if pool.router != nil {
return pool.router.writerAttach(writer)
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

when there is no router available, shouldn't this return an error ?

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 point, updating

@shollyman shollyman merged commit d382522 into googleapis:main Mar 2, 2023
@shollyman shollyman deleted the extend-poolrouter branch March 2, 2023 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants