Skip to content

Commit

Permalink
Extract client name lookup to a method (#1732)
Browse files Browse the repository at this point in the history
  • Loading branch information
jguerra authored Jan 26, 2024
1 parent 7ccbbae commit 8fd305b
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1061,11 +1061,7 @@ protected NettyOrigin getOrigin(HttpRequestMessage request) {
return null;
}

// make sure the restClientName will never be a raw VIP in cases where it's the fallback for another route
// assignment
String restClientVIP = primaryRoute;
boolean useFullName = context.getBoolean(CommonContextKeys.USE_FULL_VIP_NAME);
String restClientName = useFullName ? restClientVIP : VipUtils.getVIPPrefix(restClientVIP);
String restClientName = getClientName(context);

NettyOrigin origin = null;
// allow implementors to override the origin with custom injection logic
Expand All @@ -1075,7 +1071,7 @@ protected NettyOrigin getOrigin(HttpRequestMessage request) {
origin = getOrCreateOrigin(originManager, overrideOriginName, request.reconstructURI(), context);
} else if (restClientName != null) {
// This is the normal flow - that a RoutingFilter has assigned a route
OriginName originName = OriginName.fromVip(restClientVIP, restClientName);
OriginName originName = OriginName.fromVip(primaryRoute, restClientName);
origin = getOrCreateOrigin(originManager, originName, request.reconstructURI(), context);
}

Expand All @@ -1094,6 +1090,14 @@ protected NettyOrigin getOrigin(HttpRequestMessage request) {
return origin;
}

protected String getClientName(SessionContext context) {
// make sure the restClientName will never be a raw VIP in cases where it's the fallback for another route
// assignment
String restClientVIP = context.getRouteVIP();
boolean useFullName = context.getBoolean(CommonContextKeys.USE_FULL_VIP_NAME);
return useFullName ? restClientVIP : VipUtils.getVIPPrefix(restClientVIP);
}

/**
* Inject your own custom VIP based on your own processing
*
Expand Down

0 comments on commit 8fd305b

Please sign in to comment.