1 // 2 // Copyright 2019 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_RESOLVER_XDS_XDS_RESOLVER_ATTRIBUTES_H 18 #define GRPC_SRC_CORE_RESOLVER_XDS_XDS_RESOLVER_ATTRIBUTES_H 19 20 #include <grpc/support/port_platform.h> 21 22 #include "absl/strings/string_view.h" 23 24 #include "src/core/lib/gprpp/unique_type_name.h" 25 #include "src/core/service_config/service_config_call_data.h" 26 27 namespace grpc_core { 28 29 class XdsClusterAttribute final 30 : public ServiceConfigCallData::CallAttributeInterface { 31 public: TypeName()32 static UniqueTypeName TypeName() { 33 static UniqueTypeName::Factory kFactory("xds_cluster_name"); 34 return kFactory.Create(); 35 } 36 XdsClusterAttribute(absl::string_view cluster)37 explicit XdsClusterAttribute(absl::string_view cluster) : cluster_(cluster) {} 38 cluster()39 absl::string_view cluster() const { return cluster_; } set_cluster(absl::string_view cluster)40 void set_cluster(absl::string_view cluster) { cluster_ = cluster; } 41 42 private: type()43 UniqueTypeName type() const override { return TypeName(); } 44 45 absl::string_view cluster_; 46 }; 47 48 class XdsRouteStateAttribute 49 : public ServiceConfigCallData::CallAttributeInterface { 50 public: TypeName()51 static UniqueTypeName TypeName() { 52 static UniqueTypeName::Factory factory("xds_route_state"); 53 return factory.Create(); 54 } 55 56 virtual bool HasClusterForRoute(absl::string_view cluster_name) const = 0; type()57 UniqueTypeName type() const override { return TypeName(); } 58 }; 59 60 } // namespace grpc_core 61 62 #endif // GRPC_SRC_CORE_RESOLVER_XDS_XDS_RESOLVER_ATTRIBUTES_H 63