Skip to content

Commit

Permalink
chore: Add domain name to the CloudSqlInstanceName value object
Browse files Browse the repository at this point in the history
  • Loading branch information
hessjcg committed Jan 14, 2025
1 parent 773e99a commit cf8fc9d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,25 @@ class CloudSqlInstanceName {
private final String regionId;
private final String instanceId;
private final String connectionName;
private final String domainName;

/**
* Initializes a new CloudSqlInstanceName class.
*
* @param connectionName instance connection name in the format "PROJECT_ID:REGION_ID:INSTANCE_ID"
*/
CloudSqlInstanceName(String connectionName) {
this(connectionName, null);
}

/**
* Initializes a new CloudSqlInstanceName class containing the domain name.
*
* @param connectionName
*/
CloudSqlInstanceName(String connectionName, String domainName) {
this.connectionName = connectionName;
this.domainName = domainName;
Matcher matcher = CONNECTION_NAME.matcher(connectionName);
checkArgument(
matcher.matches(),
Expand Down Expand Up @@ -71,6 +82,10 @@ String getInstanceId() {
return instanceId;
}

String getDomainName() {
return domainName;
}

@Override
public String toString() {
return connectionName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ public LazyRefreshConnectionInfoCache(
ConnectionInfoRepository connectionInfoRepository,
CredentialFactory tokenSourceFactory,
KeyPair keyPair) {

CloudSqlInstanceName instanceName =
new CloudSqlInstanceName(config.getCloudSqlInstance(), config.getDomainName());

this.config = config;
this.instanceName = new CloudSqlInstanceName(config.getCloudSqlInstance());
this.instanceName = instanceName;

AccessTokenSupplier accessTokenSupplier =
DefaultAccessTokenSupplier.newInstance(config.getAuthType(), tokenSourceFactory);
CloudSqlInstanceName instanceName = new CloudSqlInstanceName(config.getCloudSqlInstance());

this.refreshStrategy =
new LazyRefreshStrategy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ public RefreshAheadConnectionInfoCache(
ListeningScheduledExecutorService executor,
ListenableFuture<KeyPair> keyPair,
long minRefreshDelayMs) {

CloudSqlInstanceName instanceName =
new CloudSqlInstanceName(config.getCloudSqlInstance(), config.getDomainName());

this.config = config;
this.instanceName = new CloudSqlInstanceName(config.getCloudSqlInstance());
this.instanceName = instanceName;

AccessTokenSupplier accessTokenSupplier =
DefaultAccessTokenSupplier.newInstance(config.getAuthType(), tokenSourceFactory);
CloudSqlInstanceName instanceName = new CloudSqlInstanceName(config.getCloudSqlInstance());

this.refreshStrategy =
new RefreshAheadStrategy(
Expand Down

0 comments on commit cf8fc9d

Please sign in to comment.