Package io.grpc.xds

Class RoutingUtils

java.lang.Object
io.grpc.xds.RoutingUtils

final class RoutingUtils extends Object
Utilities for performing virtual host domain name matching and route matching.
  • Constructor Details

    • RoutingUtils

      private RoutingUtils()
  • Method Details

    • findVirtualHostForHostName

      @Nullable static VirtualHost findVirtualHostForHostName(List<VirtualHost> virtualHosts, String hostName)
      Returns the VirtualHost with the best match domain for the given hostname.
    • matchHostName

      private static boolean matchHostName(String hostName, String pattern)
      Returns true iff hostName matches the domain name pattern with case-insensitive.

      Wildcard pattern rules:

      1. A single asterisk (*) matches any domain.
      2. 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, String fullMethodName, io.grpc.Metadata headers, ThreadSafeRandom random)
      Returns true iff the given VirtualHost.Route.RouteMatch matches the RPC's full method name and headers.
    • matchPath

      private static boolean matchPath(VirtualHost.Route.RouteMatch.PathMatcher pathMatcher, String fullMethodName)
    • getHeaderValue

      @Nullable private static String getHeaderValue(io.grpc.Metadata headers, String headerName)