-
Notifications
You must be signed in to change notification settings - Fork 118
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
chore: Extract internal connector registry implementation #1645
Conversation
0aebaac
to
d0a45f8
Compare
3b08337
to
5bad2c6
Compare
d0a45f8
to
3f48b01
Compare
3f48b01
to
ffd79e4
Compare
5bad2c6
to
dce5da6
Compare
dce5da6
to
44fa854
Compare
ffd79e4
to
d96b84d
Compare
d96b84d
to
e1064d0
Compare
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.
LGTM
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.
Let's frame this as "extract internal-only registry" as we're leaving CoreSocketFactory in place.
core/src/main/java/com/google/cloud/sql/core/CloudSqlConnectorRegistry.java
Outdated
Show resolved
Hide resolved
* Factory responsible for obtaining an ephemeral certificate, if necessary, and establishing a | ||
* secure connecting to a Cloud SQL instance. | ||
* | ||
* <p>This class should not be used directly, but only through the JDBC driver specific {@code |
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.
Let's make it crystal clear: "Internal class made public for module usage only. This is not part of the official public API and should not be used directly." Or something similar.
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.
Perhaps with a "WARNING" or similar call-out to lead in.
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.
@hessjcg let's add some more warnings to the doc string.
core/src/main/java/com/google/cloud/sql/core/CoreSocketFactory.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/google/cloud/sql/core/CloudSqlConnectorRegistryTest.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
/** Returns the {@link CloudSqlConnectorRegistry} singleton. */ | ||
public static synchronized CloudSqlConnectorRegistry getInstance() { |
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.
Does this need to be public? I know we're going to turn this into an enum as we have in AlloyDB, but shall we keep the API surface as small as possible during that refactor?
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 needs to be public so that it can be accessed by com.google.cloud.sql.ConnectorRegistry
, which is in a different package. We can look into restricting external access to the core
package using Java Modules some day.
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.
OK that's fine. Let's make it clear that this is a "private" method in that case with a similar warning.
* | ||
* @throws IllegalStateException if the SQLAdmin client has already been initialized | ||
*/ | ||
public static void setApplicationName(String applicationName) { |
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.
What shall we do about this? I forget what the plan here was.
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.
We're going to deprecate this method in favor of ConnectorRegistry.addApplicationId(String id)
.
e1064d0
to
37b59c7
Compare
37b59c7
to
b31f67d
Compare
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.
LGTM
I'd like to see some serious warnings around our public methods on the InternalConnectorRegistry before we merge this.
I added warnings in a few places about internal classes. |
8e155fc
to
a5d2892
Compare
* SocketFactory} implementations. | ||
* | ||
* <p>The API of this class is subject to change without notice. | ||
* @deprecated This will soon be replaced. |
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.
Replaced with what? Can we be more specific so if someone sees this they'll know what to look for and do instead?
HttpRequestInitializer credential = instanceCredentialFactory.create(); | ||
DefaultConnectionInfoRepository adminApi = | ||
connectionInfoRepositoryFactory.create(credential, config); | ||
@Deprecated |
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.
Should we mention what people should do instead?
|
||
/** | ||
* Factory responsible for obtaining an ephemeral certificate, if necessary, and establishing a | ||
* secure connecting to a Cloud SQL instance. | ||
* WARNING: This class is not a stable, public Java API. The class definition may change without |
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.
I think we put this in the wrong place -- this needs to be on the InternalConnectorRegistry.
The bit about compatibility should stay.
import jnr.unixsocket.UnixSocketChannel; | ||
|
||
/** | ||
* Factory responsible for obtaining an ephemeral certificate, if necessary, and establishing a |
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 isn't a factory. It's a holder of registered connectors. All the connection related code will move into a Connector in future commits.
* change without notice. | ||
* | ||
* <p>Package com.google.cloud.sql.core holds internal shared packages that implement logic to |
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.
Let's add a note about com.google.cloud.sql as holding all the public API.
ff6cf84
to
24bde1a
Compare
Move the connector registry implementation out of CoreSocketFactory and into InternalConnectorRegistry.
CoreSocketFactory is deprecated and contains only the static public methods used informally by other projects.
It delegates to the InternalConnectorRegistry.