1 // 2 // Copyright 2023 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_LOAD_BALANCING_XDS_XDS_OVERRIDE_HOST_H 18 #define GRPC_SRC_CORE_LOAD_BALANCING_XDS_XDS_OVERRIDE_HOST_H 19 20 #include <grpc/support/port_platform.h> 21 22 #include "absl/strings/string_view.h" 23 24 #include "src/core/lib/gprpp/ref_counted_ptr.h" 25 #include "src/core/lib/gprpp/validation_errors.h" 26 #include "src/core/lib/json/json.h" 27 #include "src/core/lib/json/json_args.h" 28 #include "src/core/lib/json/json_object_loader.h" 29 #include "src/core/load_balancing/lb_policy.h" 30 31 namespace grpc_core { 32 33 // Config for stateful session LB policy. 34 class XdsOverrideHostLbConfig final : public LoadBalancingPolicy::Config { 35 public: 36 XdsOverrideHostLbConfig() = default; 37 38 XdsOverrideHostLbConfig(const XdsOverrideHostLbConfig&) = delete; 39 XdsOverrideHostLbConfig& operator=(const XdsOverrideHostLbConfig&) = delete; 40 41 XdsOverrideHostLbConfig(XdsOverrideHostLbConfig&& other) = delete; 42 XdsOverrideHostLbConfig& operator=(XdsOverrideHostLbConfig&& other) = delete; 43 Name()44 static absl::string_view Name() { return "xds_override_host_experimental"; } 45 name()46 absl::string_view name() const override { return Name(); } 47 cluster_name()48 const std::string& cluster_name() const { return cluster_name_; } child_config()49 RefCountedPtr<LoadBalancingPolicy::Config> child_config() const { 50 return child_config_; 51 } 52 53 static const JsonLoaderInterface* JsonLoader(const JsonArgs&); 54 void JsonPostLoad(const Json& json, const JsonArgs&, 55 ValidationErrors* errors); 56 57 private: 58 std::string cluster_name_; 59 RefCountedPtr<LoadBalancingPolicy::Config> child_config_; 60 }; 61 62 } // namespace grpc_core 63 #endif // GRPC_SRC_CORE_LOAD_BALANCING_XDS_XDS_OVERRIDE_HOST_H 64