• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grpc / grpc-java / #19671

30 Jan 2025 08:43PM UTC coverage: 88.581% (-0.01%) from 88.595%
#19671

push

github

web-flow
xds: Reuse filter interceptors across RPCs

This moves the interceptor creation from the ConfigSelector to the
resource update handling.

The code structure changes will make adding support for filter
lifecycles (for RLQS) a bit easier. The filter lifecycles will allow
filters to share state across interceptors, and constructing all the
interceptors on a single thread will mean filters wouldn't need to be
thread-safe (but their interceptors would be thread-safe).

33760 of 38112 relevant lines covered (88.58%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/../xds/src/main/java/io/grpc/xds/RouterFilter.java
1
/*
2
 * Copyright 2021 The gRPC Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package io.grpc.xds;
18

19
import com.google.protobuf.Message;
20
import io.grpc.ClientInterceptor;
21
import io.grpc.ServerInterceptor;
22
import io.grpc.xds.Filter.ClientInterceptorBuilder;
23
import io.grpc.xds.Filter.ServerInterceptorBuilder;
24
import java.util.concurrent.ScheduledExecutorService;
25
import javax.annotation.Nullable;
26

27
/**
28
 * Router filter implementation. Currently this filter does not parse any field in the config.
29
 */
30
enum RouterFilter implements Filter, ClientInterceptorBuilder, ServerInterceptorBuilder {
1✔
31
  INSTANCE;
1✔
32

33
  static final String TYPE_URL =
34
      "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router";
35

36
  static final FilterConfig ROUTER_CONFIG = new FilterConfig() {
1✔
37
    @Override
38
    public String typeUrl() {
39
      return RouterFilter.TYPE_URL;
1✔
40
    }
41

42
    @Override
43
    public String toString() {
44
      return "ROUTER_CONFIG";
1✔
45
    }
46
  };
47

48
  @Override
49
  public String[] typeUrls() {
50
    return new String[] { TYPE_URL };
1✔
51
  }
52

53
  @Override
54
  public ConfigOrError<? extends FilterConfig> parseFilterConfig(Message rawProtoMessage) {
55
    return ConfigOrError.fromConfig(ROUTER_CONFIG);
1✔
56
  }
57

58
  @Override
59
  public ConfigOrError<? extends FilterConfig> parseFilterConfigOverride(Message rawProtoMessage) {
60
    return ConfigOrError.fromError("Router Filter should not have override config");
×
61
  }
62

63
  @Nullable
64
  @Override
65
  public ClientInterceptor buildClientInterceptor(
66
      FilterConfig config, @Nullable FilterConfig overrideConfig,
67
      ScheduledExecutorService scheduler) {
68
    return null;
1✔
69
  }
70

71
  @Nullable
72
  @Override
73
  public ServerInterceptor buildServerInterceptor(
74
      FilterConfig config, @Nullable Filter.FilterConfig overrideConfig) {
75
    return null;
1✔
76
  }
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc