Skip to content

Commit

Permalink
feat: Add comments for EndpointContext
Browse files Browse the repository at this point in the history
  • Loading branch information
lqiu96 committed Nov 7, 2023
1 parent 2df163f commit 9650368
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ public static Builder newBuilder() {
return new AutoValue_EndpointContext.Builder().setSwitchToMtlsEndpointAllowed(false);
}

// By default, the clientSettingsEndpoint value is the default_host endpoint
// value configured in the service. Users can override this value by the Setter
// exposed in the Client/Stub Settings or in the TransportChannelProvider.
@VisibleForTesting
void determineEndpoint() throws IOException {
if (resolvedEndpoint != null && resolvedUniverseDomain != null) {
Expand All @@ -93,7 +90,7 @@ void determineEndpoint() throws IOException {
MtlsProvider mtlsProvider = mtlsProvider() == null ? new MtlsProvider() : mtlsProvider();
String customEndpoint =
transportChannelEndpoint() != null ? transportChannelEndpoint() : clientSettingsEndpoint();
// This means that there are no user configured endpoints, use the default endpoint
// If there are no user configured endpoints, use the default endpoints
if (customEndpoint == null) {
if (switchToMtlsEndpointAllowed() && mtlsProvider != null) {
resolvedEndpoint =
Expand All @@ -105,7 +102,8 @@ void determineEndpoint() throws IOException {
return;
}
Matcher matcher = ENDPOINT_REGEX.matcher(customEndpoint);
// Check if it matches the ENDPOINT_TEMPLATE format
// Check if it matches the ENDPOINT_TEMPLATE format, otherwise use the
// custom set endpoint
if (!matcher.matches()) {
resolvedEndpoint = customEndpoint;
resolvedUniverseDomain = GOOGLE_DEFAULT_UNIVERSE;
Expand All @@ -126,11 +124,12 @@ void determineEndpoint() throws IOException {
customEndpoint = customEndpoint.substring(8);
}

// Parse the custom endpoint for the service name, universe domain, and the port
int periodIndex = customEndpoint.indexOf('.');
int colonIndex = customEndpoint.indexOf(':');
String serviceName = customEndpoint.substring(0, periodIndex);
String universeDomain;
String port = "443";
String port = DEFAULT_PORT;
if (colonIndex != -1) {
universeDomain = customEndpoint.substring(periodIndex + 1, colonIndex);
port = customEndpoint.substring(colonIndex + 1);
Expand Down

0 comments on commit 9650368

Please sign in to comment.