1 // 2 // Copyright 2018 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 #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_ROUTE_CONFIG_PARSER_H 18 #define GRPC_SRC_CORE_XDS_GRPC_XDS_ROUTE_CONFIG_PARSER_H 19 20 #include <grpc/support/port_platform.h> 21 #include <stdint.h> 22 23 #include <algorithm> 24 #include <map> 25 #include <memory> 26 #include <string> 27 #include <vector> 28 29 #include "absl/strings/string_view.h" 30 #include "absl/types/optional.h" 31 #include "absl/types/variant.h" 32 #include "envoy/config/route/v3/route.upb.h" 33 #include "envoy/config/route/v3/route.upbdefs.h" 34 #include "re2/re2.h" 35 #include "src/core/lib/channel/status_util.h" 36 #include "src/core/util/time.h" 37 #include "src/core/util/validation_errors.h" 38 #include "src/core/xds/grpc/xds_bootstrap_grpc.h" 39 #include "src/core/xds/grpc/xds_cluster_specifier_plugin.h" 40 #include "src/core/xds/grpc/xds_http_filter.h" 41 #include "src/core/xds/grpc/xds_route_config.h" 42 #include "src/core/xds/xds_client/xds_client.h" 43 #include "src/core/xds/xds_client/xds_resource_type.h" 44 #include "src/core/xds/xds_client/xds_resource_type_impl.h" 45 #include "upb/reflection/def.h" 46 47 namespace grpc_core { 48 49 std::shared_ptr<const XdsRouteConfigResource> XdsRouteConfigResourceParse( 50 const XdsResourceType::DecodeContext& context, 51 const envoy_config_route_v3_RouteConfiguration* route_config, 52 ValidationErrors* errors); 53 54 class XdsRouteConfigResourceType final 55 : public XdsResourceTypeImpl<XdsRouteConfigResourceType, 56 XdsRouteConfigResource> { 57 public: type_url()58 absl::string_view type_url() const override { 59 return "envoy.config.route.v3.RouteConfiguration"; 60 } 61 62 DecodeResult Decode(const XdsResourceType::DecodeContext& context, 63 absl::string_view serialized_resource) const override; 64 InitUpbSymtab(XdsClient * xds_client,upb_DefPool * symtab)65 void InitUpbSymtab(XdsClient* xds_client, 66 upb_DefPool* symtab) const override { 67 envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab); 68 const auto& cluster_specifier_plugin_registry = 69 static_cast<const GrpcXdsBootstrap&>(xds_client->bootstrap()) 70 .cluster_specifier_plugin_registry(); 71 cluster_specifier_plugin_registry.PopulateSymtab(symtab); 72 } 73 }; 74 75 } // namespace grpc_core 76 77 #endif // GRPC_SRC_CORE_XDS_GRPC_XDS_ROUTE_CONFIG_PARSER_H 78