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