Skip to content

Commit bd291c0

Browse files
committed
chore: Add domain name to the CloudSqlInstanceName value object
1 parent 773e99a commit bd291c0

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

core/src/main/java/com/google/cloud/sql/core/CloudSqlInstanceName.java

+15
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,25 @@ class CloudSqlInstanceName {
3535
private final String regionId;
3636
private final String instanceId;
3737
private final String connectionName;
38+
private final String domainName;
3839

3940
/**
4041
* Initializes a new CloudSqlInstanceName class.
4142
*
4243
* @param connectionName instance connection name in the format "PROJECT_ID:REGION_ID:INSTANCE_ID"
4344
*/
4445
CloudSqlInstanceName(String connectionName) {
46+
this(connectionName, null);
47+
}
48+
49+
/**
50+
* Initializes a new CloudSqlInstanceName class containing the domain name.
51+
*
52+
* @param connectionName
53+
*/
54+
CloudSqlInstanceName(String connectionName, String domainName) {
4555
this.connectionName = connectionName;
56+
this.domainName = domainName;
4657
Matcher matcher = CONNECTION_NAME.matcher(connectionName);
4758
checkArgument(
4859
matcher.matches(),
@@ -71,6 +82,10 @@ String getInstanceId() {
7182
return instanceId;
7283
}
7384

85+
String getDomainName() {
86+
return domainName;
87+
}
88+
7489
@Override
7590
public String toString() {
7691
return connectionName;

core/src/main/java/com/google/cloud/sql/core/LazyRefreshConnectionInfoCache.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ public LazyRefreshConnectionInfoCache(
4444
ConnectionInfoRepository connectionInfoRepository,
4545
CredentialFactory tokenSourceFactory,
4646
KeyPair keyPair) {
47+
48+
CloudSqlInstanceName instanceName =
49+
new CloudSqlInstanceName(config.getCloudSqlInstance(), config.getDomainName());
50+
4751
this.config = config;
48-
this.instanceName = new CloudSqlInstanceName(config.getCloudSqlInstance());
52+
this.instanceName = instanceName;
4953

5054
AccessTokenSupplier accessTokenSupplier =
5155
DefaultAccessTokenSupplier.newInstance(config.getAuthType(), tokenSourceFactory);
52-
CloudSqlInstanceName instanceName = new CloudSqlInstanceName(config.getCloudSqlInstance());
5356

5457
this.refreshStrategy =
5558
new LazyRefreshStrategy(

core/src/main/java/com/google/cloud/sql/core/RefreshAheadConnectionInfoCache.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@ public RefreshAheadConnectionInfoCache(
4848
ListeningScheduledExecutorService executor,
4949
ListenableFuture<KeyPair> keyPair,
5050
long minRefreshDelayMs) {
51+
52+
CloudSqlInstanceName instanceName =
53+
new CloudSqlInstanceName(config.getCloudSqlInstance(), config.getDomainName());
54+
5155
this.config = config;
52-
this.instanceName = new CloudSqlInstanceName(config.getCloudSqlInstance());
56+
this.instanceName = instanceName;
5357

5458
AccessTokenSupplier accessTokenSupplier =
5559
DefaultAccessTokenSupplier.newInstance(config.getAuthType(), tokenSourceFactory);
56-
CloudSqlInstanceName instanceName = new CloudSqlInstanceName(config.getCloudSqlInstance());
5760

5861
this.refreshStrategy =
5962
new RefreshAheadStrategy(

0 commit comments

Comments
 (0)