Package io.grpc.xds
Class RoutingUtils
- java.lang.Object
-
- io.grpc.xds.RoutingUtils
-
final class RoutingUtils extends java.lang.Object
Utilities for performing virtual host domain name matching and route matching.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
RoutingUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static VirtualHost
findVirtualHostForHostName(java.util.List<VirtualHost> virtualHosts, java.lang.String hostName)
Returns theVirtualHost
with the best match domain for the given hostname.private static java.lang.String
getHeaderValue(io.grpc.Metadata headers, java.lang.String headerName)
private static boolean
matchHostName(java.lang.String hostName, java.lang.String pattern)
Returnstrue
iffhostName
matches the domain namepattern
with case-insensitive.private static boolean
matchPath(VirtualHost.Route.RouteMatch.PathMatcher pathMatcher, java.lang.String fullMethodName)
(package private) static boolean
matchRoute(VirtualHost.Route.RouteMatch routeMatch, java.lang.String fullMethodName, io.grpc.Metadata headers, ThreadSafeRandom random)
Returnstrue
iff the givenVirtualHost.Route.RouteMatch
matches the RPC's full method name and headers.
-
-
-
Method Detail
-
findVirtualHostForHostName
@Nullable static VirtualHost findVirtualHostForHostName(java.util.List<VirtualHost> virtualHosts, java.lang.String hostName)
Returns theVirtualHost
with the best match domain for the given hostname.
-
matchHostName
private static boolean matchHostName(java.lang.String hostName, java.lang.String pattern)
Returnstrue
iffhostName
matches the domain namepattern
with case-insensitive.Wildcard pattern rules:
- A single asterisk (*) matches any domain.
- Asterisk (*) is only permitted in the left-most or the right-most part of the pattern, but not both.
-
matchRoute
static boolean matchRoute(VirtualHost.Route.RouteMatch routeMatch, java.lang.String fullMethodName, io.grpc.Metadata headers, ThreadSafeRandom random)
Returnstrue
iff the givenVirtualHost.Route.RouteMatch
matches the RPC's full method name and headers.
-
matchPath
private static boolean matchPath(VirtualHost.Route.RouteMatch.PathMatcher pathMatcher, java.lang.String fullMethodName)
-
getHeaderValue
@Nullable private static java.lang.String getHeaderValue(io.grpc.Metadata headers, java.lang.String headerName)
-
-