File tree Expand file tree Collapse file tree 4 files changed +18
-1
lines changed Expand file tree Collapse file tree 4 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ interface Filter {
38
38
*/
39
39
String [] typeUrls ();
40
40
41
+ default boolean isEnabled () {
42
+ return true ;
43
+ }
44
+
41
45
/**
42
46
* Parses the top-level filter config from raw proto message. The message may be either a {@link
43
47
* com.google.protobuf.Any} or a {@link com.google.protobuf.Struct}.
Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ static FilterRegistry newRegistry() {
51
51
@ VisibleForTesting
52
52
FilterRegistry register (Filter ... filters ) {
53
53
for (Filter filter : filters ) {
54
+ if (!filter .isEnabled ()) {
55
+ continue ;
56
+ }
54
57
for (String typeUrl : filter .typeUrls ()) {
55
58
supportedFilters .put (typeUrl , filter );
56
59
}
Original file line number Diff line number Diff line change 32
32
import io .grpc .ServerCall .Listener ;
33
33
import io .grpc .ServerCallHandler ;
34
34
import io .grpc .ServerInterceptor ;
35
+ import io .grpc .internal .GrpcUtil ;
35
36
import io .grpc .xds .Filter .ServerInterceptorBuilder ;
36
37
import io .grpc .xds .internal .datatype .GrpcService ;
37
38
import io .grpc .xds .internal .matchers .HttpMatchInput ;
50
51
// TODO(sergiitk): introduce a layer between the filter and interceptor.
51
52
// lds has filter names and the names are unique - even for server instances.
52
53
final class RlqsFilter implements Filter , ServerInterceptorBuilder {
53
- // private static final Logger logger = Logger.getLogger(RlqsFilter.class.getName() );
54
+ static final boolean enabled = GrpcUtil . getFlag ( "GRPC_EXPERIMENTAL_XDS_ENABLE_RLQS" , false );
54
55
55
56
static final RlqsFilter INSTANCE = new RlqsFilter ();
56
57
@@ -66,6 +67,11 @@ public String[] typeUrls() {
66
67
return new String []{TYPE_URL , TYPE_URL_OVERRIDE_CONFIG };
67
68
}
68
69
70
+ @ Override
71
+ public boolean isEnabled () {
72
+ return enabled ;
73
+ }
74
+
69
75
@ Override
70
76
public ConfigOrError <RlqsFilterConfig > parseFilterConfig (Message rawProtoMessage ) {
71
77
try {
Original file line number Diff line number Diff line change @@ -1118,6 +1118,8 @@ public void run() {
1118
1118
Filter filter = mock (Filter .class , withSettings ()
1119
1119
.extraInterfaces (ServerInterceptorBuilder .class ));
1120
1120
when (filter .typeUrls ()).thenReturn (new String []{"filter-type-url" });
1121
+ when (filter .isEnabled ()).thenCallRealMethod ();
1122
+ assertThat (filter .isEnabled ()).isTrue ();
1121
1123
filterRegistry .register (filter );
1122
1124
FilterConfig f0 = mock (FilterConfig .class );
1123
1125
FilterConfig f0Override = mock (FilterConfig .class );
@@ -1191,6 +1193,8 @@ public void run() {
1191
1193
Filter filter = mock (Filter .class , withSettings ()
1192
1194
.extraInterfaces (ServerInterceptorBuilder .class ));
1193
1195
when (filter .typeUrls ()).thenReturn (new String []{"filter-type-url" });
1196
+ when (filter .isEnabled ()).thenCallRealMethod ();
1197
+ assertThat (filter .isEnabled ()).isTrue ();
1194
1198
filterRegistry .register (filter );
1195
1199
FilterConfig f0 = mock (FilterConfig .class );
1196
1200
FilterConfig f0Override = mock (FilterConfig .class );
You can’t perform that action at this time.
0 commit comments