xds_lb_policy_registry.h
Go to the documentation of this file.
1 //
2 // Copyright 2022 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_CORE_EXT_XDS_XDS_LB_POLICY_REGISTRY_H
18 #define GRPC_CORE_EXT_XDS_XDS_LB_POLICY_REGISTRY_H
19 
21 
22 #include <map>
23 #include <memory>
24 
25 #include "absl/status/statusor.h"
26 #include "absl/strings/string_view.h"
28 
30 #include "src/core/lib/json/json.h"
31 
32 namespace grpc_core {
33 
34 // A registry that maintans a set of converters that are able to map xDS
35 // loadbalancing policy configurations to gRPC's JSON format.
37  public:
38  class ConfigFactory {
39  public:
40  virtual ~ConfigFactory() {}
42  const XdsEncodingContext& context, absl::string_view configuration,
43  int recursion_depth) = 0;
44 
45  virtual absl::string_view type() = 0;
46  };
47 
48  // Converts an xDS cluster load balancing policy message to gRPC's JSON
49  // format. An error is returned if none of the lb policies in the list are
50  // supported, or if a supported lb policy configuration conversion fails. \a
51  // recursion_depth indicates the current depth of the tree if lb_policy
52  // configuration recursively holds other lb policies.
56  int recursion_depth = 0);
57 
58  private:
60 
61  static XdsLbPolicyRegistry* Get();
62 
63  // A map of config factories that goes from the type of the lb policy config
64  // to the config factory.
65  std::map<absl::string_view /* Owned by ConfigFactory */,
66  std::unique_ptr<ConfigFactory>>
68 };
69 
70 } // namespace grpc_core
71 
72 #endif // GRPC_CORE_EXT_XDS_XDS_LB_POLICY_REGISTRY_H
grpc_core::XdsLbPolicyRegistry
Definition: xds_lb_policy_registry.h:36
grpc_core::XdsEncodingContext
Definition: upb_utils.h:39
grpc_core
Definition: call_metric_recorder.h:31
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
grpc_core::XdsLbPolicyRegistry::ConfigFactory::type
virtual absl::string_view type()=0
map
zval * map
Definition: php/ext/google/protobuf/encode_decode.c:480
envoy_config_cluster_v3_LoadBalancingPolicy
struct envoy_config_cluster_v3_LoadBalancingPolicy envoy_config_cluster_v3_LoadBalancingPolicy
Definition: config/cluster/v3/cluster.upb.h:68
grpc_core::XdsLbPolicyRegistry::ConfigFactory
Definition: xds_lb_policy_registry.h:38
grpc_core::XdsLbPolicyRegistry::Get
static XdsLbPolicyRegistry * Get()
Definition: xds_lb_policy_registry.cc:285
grpc_core::XdsLbPolicyRegistry::ConfigFactory::ConvertXdsLbPolicyConfig
virtual absl::StatusOr< Json::Object > ConvertXdsLbPolicyConfig(const XdsEncodingContext &context, absl::string_view configuration, int recursion_depth)=0
json.h
grpc_core::XdsLbPolicyRegistry::ConfigFactory::~ConfigFactory
virtual ~ConfigFactory()
Definition: xds_lb_policy_registry.h:40
grpc_core::XdsLbPolicyRegistry::policy_config_factories_
std::map< absl::string_view, std::unique_ptr< ConfigFactory > > policy_config_factories_
Definition: xds_lb_policy_registry.h:67
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
cluster.upb.h
absl::StatusOr
Definition: abseil-cpp/absl/status/statusor.h:187
upb_utils.h
grpc_core::XdsLbPolicyRegistry::ConvertXdsLbPolicyConfig
static absl::StatusOr< Json::Array > ConvertXdsLbPolicyConfig(const XdsEncodingContext &context, const envoy_config_cluster_v3_LoadBalancingPolicy *lb_policy, int recursion_depth=0)
Definition: xds_lb_policy_registry.cc:189
grpc_core::XdsLbPolicyRegistry::XdsLbPolicyRegistry
XdsLbPolicyRegistry()
Definition: xds_lb_policy_registry.cc:273
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:59