-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Move functions to connect to database servers to a common package #49225
Move functions to connect to database servers to a common package #49225
Conversation
This pull request is automatically being deployed by Amplify Hosting (learn more). |
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 might be a good moment to drop the shuffleFunc global var, if you feel like it.
Could you share a draft of how the new lib will be used? IMHO, |
@espadolini Friendly ping. Thanks! |
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.
Wouldn't lib/srv/db/connect
or lib/srv/db/common/connect
(maybe declared or just imported as dbconnect
) be better? The name srvconnect
doesn't really hint at it containing database access functions, and if you're going to have to read the full package path anyway, you might as well make the package name simpler.
I like how common
hints at it being good to use from outside of lib/srv/db
although maybe we should start putting things that shouldn't be used from outside of a package tree in internal
instead (as that will actually be enforced by the linker).
Part of #44956 (RFD 0181)
Context: The PostgreSQL access through WebUI requires us to establish connections to database servers from the web package (not implemented yet). This process is the same as that used by the database proxy server (
ProxyServer
). Instead of duplicating the logic in those two places, we're moving the common pieces into a shared package that both can use.This PR moves some functions to generate credentials and connect to database servers and updates the
ProxyServer
to use them. The new package includes three functions that the proxy server and the PostgreSQL access through WebUI will use:GetDatabaseServers
: List database servers that can handle a specific database. (previouslygetDatabaseServers
).GetServerTLSConfig
: Generates thetls.Config
for connecting to a database server. (previouslygetConfigForServer
).Connect
: Connects to a database server based on the provided list. (previouslyConnect
).Note
Those functions have no feature/behavior changes. They were only moved to a different package. The only changes made are in their parameters and return types. Also, this PR includes additional tests specific for those functions.