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.auto.value.AutoValue; 20 import com.google.protobuf.Message; 21 22 /** 23 * Defines the parsing functionality of a ClusterSpecifierPlugin as defined in the Enovy proto 24 * api/envoy/config/route/v3/route.proto. 25 */ 26 interface ClusterSpecifierPlugin { 27 /** 28 * The proto message types supported by this plugin. A plugin will be registered by each of its 29 * supported message types. 30 */ typeUrls()31 String[] typeUrls(); 32 parsePlugin(Message rawProtoMessage)33 ConfigOrError<? extends PluginConfig> parsePlugin(Message rawProtoMessage); 34 35 /** Represents an opaque data structure holding configuration for a ClusterSpecifierPlugin. */ 36 interface PluginConfig { typeUrl()37 String typeUrl(); 38 } 39 40 @AutoValue 41 abstract class NamedPluginConfig { name()42 abstract String name(); 43 config()44 abstract PluginConfig config(); 45 create(String name, PluginConfig config)46 static NamedPluginConfig create(String name, PluginConfig config) { 47 return new AutoValue_ClusterSpecifierPlugin_NamedPluginConfig(name, config); 48 } 49 } 50 } 51