MCPcopy Create free account
hub / github.com/grpc/grpc-java / matchRoute

Method matchRoute

xds/src/main/java/io/grpc/xds/RoutingUtils.java:146–158  ·  view source on GitHub ↗

Returns true iff the given RouteMatch matches the RPC's full method name and headers.

(RouteMatch routeMatch, String fullMethodName,
      Metadata headers, ThreadSafeRandom random)

Source from the content-addressed store, hash-verified

144 * headers.
145 */
146 static boolean matchRoute(RouteMatch routeMatch, String fullMethodName,
147 Metadata headers, ThreadSafeRandom random) {
148 if (!matchPath(routeMatch.pathMatcher(), fullMethodName)) {
149 return false;
150 }
151 for (HeaderMatcher headerMatcher : routeMatch.headerMatchers()) {
152 if (!headerMatcher.matches(getHeaderValue(headers, headerMatcher.name()))) {
153 return false;
154 }
155 }
156 FractionMatcher fraction = routeMatch.fractionMatcher();
157 return fraction == null || random.nextInt(fraction.denominator()) < fraction.numerator();
158 }
159
160 private static boolean matchPath(PathMatcher pathMatcher, String fullMethodName) {
161 if (pathMatcher.path() != null) {

Callers 5

selectConfigMethod · 0.95
interceptCallMethod · 0.95

Calls 10

matchPathMethod · 0.95
getHeaderValueMethod · 0.95
denominatorMethod · 0.95
numeratorMethod · 0.95
headerMatchersMethod · 0.80
fractionMatcherMethod · 0.80
matchesMethod · 0.65
nextIntMethod · 0.65
pathMatcherMethod · 0.45
nameMethod · 0.45