Skip to content

Commit

Permalink
Merge pull request cdapio#15511 from cdapio/bugfix/CDAP-20924-use-int…
Browse files Browse the repository at this point in the history
…ernal-router

[CDAP-20924] Use internal router for creating remote clients when configured and using alternate factory method
  • Loading branch information
arjan-bal authored Dec 18, 2023
2 parents 6ac5fd1 + ca37c4f commit 1ae1852
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,8 @@ public RemoteClientFactory(DiscoveryServiceClient discoveryClient,
*/
public RemoteClient createRemoteClient(String discoverableServiceName,
HttpRequestConfig httpRequestConfig, String basePath) {
basePath = basePath.startsWith("/") ? pathPrefix + basePath
: pathPrefix + "/" + basePath;
if (this.internalRouterEnabled) {
return getClientForInternalRouter(discoverableServiceName,
httpRequestConfig, basePath);
}
return new RemoteClient(internalAuthenticator, discoveryClient,
discoverableServiceName, httpRequestConfig, basePath,
remoteAuthenticator);
return createRemoteClient(discoverableServiceName, httpRequestConfig,
basePath, internalAuthenticator);
}

/**
Expand All @@ -143,12 +136,18 @@ public RemoteClient createRemoteClient(String discoverableServiceName,
HttpRequestConfig httpRequestConfig, String basePath,
InternalAuthenticator internalAuthenticator) {
basePath = basePath.startsWith("/") ? pathPrefix + basePath : pathPrefix + "/" + basePath;
return new RemoteClient(internalAuthenticator, discoveryClient, discoverableServiceName,
if (this.internalRouterEnabled) {
return getClientForInternalRouter(discoverableServiceName,
httpRequestConfig, basePath, internalAuthenticator);
}
return new RemoteClient(internalAuthenticator, discoveryClient,
discoverableServiceName,
httpRequestConfig, basePath, remoteAuthenticator);
}

private RemoteClient getClientForInternalRouter(String destinationServiceName,
HttpRequestConfig httpRequestConfig, String basePath) {
HttpRequestConfig httpRequestConfig, String basePath,
InternalAuthenticator internalAuthenticator) {
LOG.trace(
"Creating client for service '{}' which routes through service '{}'.",
destinationServiceName, Service.INTERNAL_ROUTER);
Expand Down

0 comments on commit 1ae1852

Please sign in to comment.