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

grpc / grpc-java / #18797

17 Aug 2023 11:32PM UTC coverage: 88.278% (-0.03%) from 88.304%
#18797

push

github-actions

web-flow
buildscripts: add missing $GRADLE_FLAGS to enable AndroidX (#10504)

30342 of 34371 relevant lines covered (88.28%)

0.88 hits per line

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

62.5
/../xds/src/main/java/io/grpc/xds/Filter.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.common.base.MoreObjects;
20
import com.google.protobuf.Message;
21
import io.grpc.ClientInterceptor;
22
import io.grpc.LoadBalancer.PickSubchannelArgs;
23
import io.grpc.ServerInterceptor;
24
import java.util.Objects;
25
import java.util.concurrent.ScheduledExecutorService;
26
import javax.annotation.Nullable;
27

28
/**
29
 * Defines the parsing functionality of an HTTP filter. A Filter may optionally implement either
30
 * {@link ClientInterceptorBuilder} or {@link ServerInterceptorBuilder} or both, indicating it is
31
 * capable of working on the client side or server side or both, respectively.
32
 */
33
interface Filter {
34

35
  /**
36
   * The proto message types supported by this filter. A filter will be registered by each of its
37
   * supported message types.
38
   */
39
  String[] typeUrls();
40

41
  /**
42
   * Parses the top-level filter config from raw proto message. The message may be either a {@link
43
   * com.google.protobuf.Any} or a {@link com.google.protobuf.Struct}.
44
   */
45
  ConfigOrError<? extends FilterConfig> parseFilterConfig(Message rawProtoMessage);
46

47
  /**
48
   * Parses the per-filter override filter config from raw proto message. The message may be either
49
   * a {@link com.google.protobuf.Any} or a {@link com.google.protobuf.Struct}.
50
   */
51
  ConfigOrError<? extends FilterConfig> parseFilterConfigOverride(Message rawProtoMessage);
52

53
  /** Represents an opaque data structure holding configuration for a filter. */
54
  interface FilterConfig {
55
    String typeUrl();
56
  }
57

58
  /** Uses the FilterConfigs produced above to produce an HTTP filter interceptor for clients. */
59
  interface ClientInterceptorBuilder {
60
    @Nullable
61
    ClientInterceptor buildClientInterceptor(
62
        FilterConfig config, @Nullable FilterConfig overrideConfig, PickSubchannelArgs args,
63
        ScheduledExecutorService scheduler);
64
  }
65

66
  /** Uses the FilterConfigs produced above to produce an HTTP filter interceptor for the server. */
67
  interface ServerInterceptorBuilder {
68
    @Nullable
69
    ServerInterceptor buildServerInterceptor(
70
        FilterConfig config, @Nullable FilterConfig overrideConfig);
71
  }
72

73
  /** Filter config with instance name. */
74
  final class NamedFilterConfig {
75
    // filter instance name
76
    final String name;
77
    final FilterConfig filterConfig;
78

79
    NamedFilterConfig(String name, FilterConfig filterConfig) {
1✔
80
      this.name = name;
1✔
81
      this.filterConfig = filterConfig;
1✔
82
    }
1✔
83

84
    @Override
85
    public boolean equals(Object o) {
86
      if (this == o) {
1✔
87
        return true;
×
88
      }
89
      if (o == null || getClass() != o.getClass()) {
1✔
90
        return false;
×
91
      }
92
      NamedFilterConfig that = (NamedFilterConfig) o;
1✔
93
      return Objects.equals(name, that.name)
1✔
94
          && Objects.equals(filterConfig, that.filterConfig);
1✔
95
    }
96

97
    @Override
98
    public int hashCode() {
99
      return Objects.hash(name, filterConfig);
1✔
100
    }
101

102
    @Override
103
    public String toString() {
104
      return MoreObjects.toStringHelper(this)
×
105
          .add("name", name)
×
106
          .add("filterConfig", filterConfig)
×
107
          .toString();
×
108
    }
109
  }
110
}
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