summaryrefslogtreecommitdiff
path: root/grpc/src/core/ext/xds/xds_cluster.h
diff options
context:
space:
mode:
authorShuo Wang Hsu <shuohsu@google.com>2024-01-02 16:54:20 -0800
committerShuo Wang Hsu <shuohsu@google.com>2024-01-02 16:54:22 -0800
commit67249fccf527662d90aed4eed2181fdd4cb682e3 (patch)
tree38fcc3ed3fb25375eaf918489ea17913adca8ebe /grpc/src/core/ext/xds/xds_cluster.h
parentdde934ee51d1a9fa5562284fb0aface52c7adc2e (diff)
downloadgrpcio-sys-67249fccf527662d90aed4eed2181fdd4cb682e3.tar.gz
Upgrade grpcio-sys to 0.13.0+1.56.2-patched
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update rust/crates/grpcio-sys For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: Ife139c5ce97cbc54042f0820fe3caee5a7bdf083
Diffstat (limited to 'grpc/src/core/ext/xds/xds_cluster.h')
-rw-r--r--grpc/src/core/ext/xds/xds_cluster.h108
1 files changed, 68 insertions, 40 deletions
diff --git a/grpc/src/core/ext/xds/xds_cluster.h b/grpc/src/core/ext/xds/xds_cluster.h
index 5ac020fe..878f7954 100644
--- a/grpc/src/core/ext/xds/xds_cluster.h
+++ b/grpc/src/core/ext/xds/xds_cluster.h
@@ -14,66 +14,98 @@
// limitations under the License.
//
-#ifndef GRPC_CORE_EXT_XDS_XDS_CLUSTER_H
-#define GRPC_CORE_EXT_XDS_XDS_CLUSTER_H
+#ifndef GRPC_SRC_CORE_EXT_XDS_XDS_CLUSTER_H
+#define GRPC_SRC_CORE_EXT_XDS_XDS_CLUSTER_H
#include <grpc/support/port_platform.h>
+#include <stdint.h>
+
+#include <algorithm>
+#include <memory>
+#include <set>
#include <string>
#include <vector>
+#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
+#include "absl/types/variant.h"
#include "envoy/config/cluster/v3/cluster.upbdefs.h"
#include "envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.h"
#include "envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h"
+#include "upb/reflection/def.h"
+#include "src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h"
+#include "src/core/ext/xds/xds_bootstrap.h"
+#include "src/core/ext/xds/xds_bootstrap_grpc.h"
#include "src/core/ext/xds/xds_client.h"
#include "src/core/ext/xds/xds_common_types.h"
+#include "src/core/ext/xds/xds_health_status.h"
+#include "src/core/ext/xds/xds_resource_type.h"
#include "src/core/ext/xds/xds_resource_type_impl.h"
+#include "src/core/lib/json/json.h"
namespace grpc_core {
-struct XdsClusterResource {
- enum ClusterType { EDS, LOGICAL_DNS, AGGREGATE };
- ClusterType cluster_type;
- // For cluster type EDS.
- // The name to use in the EDS request.
- // If empty, the cluster name will be used.
- std::string eds_service_name;
- // For cluster type LOGICAL_DNS.
- // The hostname to lookup in DNS.
- std::string dns_hostname;
- // For cluster type AGGREGATE.
- // The prioritized list of cluster names.
- std::vector<std::string> prioritized_cluster_names;
+bool XdsOverrideHostEnabled();
- // Tls Context used by clients
- CommonTlsContext common_tls_context;
+struct XdsClusterResource : public XdsResourceType::ResourceData {
+ struct Eds {
+ // If empty, defaults to the cluster name.
+ std::string eds_service_name;
+
+ bool operator==(const Eds& other) const {
+ return eds_service_name == other.eds_service_name;
+ }
+ };
+
+ struct LogicalDns {
+ // The hostname to lookup in DNS.
+ std::string hostname;
+
+ bool operator==(const LogicalDns& other) const {
+ return hostname == other.hostname;
+ }
+ };
+
+ struct Aggregate {
+ // Prioritized list of cluster names.
+ std::vector<std::string> prioritized_cluster_names;
+
+ bool operator==(const Aggregate& other) const {
+ return prioritized_cluster_names == other.prioritized_cluster_names;
+ }
+ };
+
+ absl::variant<Eds, LogicalDns, Aggregate> type;
+
+ // The LB policy to use for locality and endpoint picking.
+ Json::Array lb_policy_config;
+
+ // Note: Remaining fields are not used for aggregate clusters.
// The LRS server to use for load reporting.
// If not set, load reporting will be disabled.
- absl::optional<XdsBootstrap::XdsServer> lrs_load_reporting_server;
+ absl::optional<GrpcXdsBootstrap::GrpcXdsServer> lrs_load_reporting_server;
+
+ // Tls Context used by clients
+ CommonTlsContext common_tls_context;
- // The LB policy to use (e.g., "ROUND_ROBIN" or "RING_HASH").
- std::string lb_policy;
- // Used for RING_HASH LB policy only.
- uint64_t min_ring_size = 1024;
- uint64_t max_ring_size = 8388608;
// Maximum number of outstanding requests can be made to the upstream
// cluster.
uint32_t max_concurrent_requests = 1024;
+ absl::optional<OutlierDetectionConfig> outlier_detection;
+
+ std::set<XdsHealthStatus> override_host_statuses;
+
bool operator==(const XdsClusterResource& other) const {
- return cluster_type == other.cluster_type &&
- eds_service_name == other.eds_service_name &&
- dns_hostname == other.dns_hostname &&
- prioritized_cluster_names == other.prioritized_cluster_names &&
- common_tls_context == other.common_tls_context &&
+ return type == other.type && lb_policy_config == other.lb_policy_config &&
lrs_load_reporting_server == other.lrs_load_reporting_server &&
- lb_policy == other.lb_policy &&
- min_ring_size == other.min_ring_size &&
- max_ring_size == other.max_ring_size &&
- max_concurrent_requests == other.max_concurrent_requests;
+ common_tls_context == other.common_tls_context &&
+ max_concurrent_requests == other.max_concurrent_requests &&
+ outlier_detection == other.outlier_detection &&
+ override_host_statuses == other.override_host_statuses;
}
std::string ToString() const;
@@ -85,17 +117,13 @@ class XdsClusterResourceType
absl::string_view type_url() const override {
return "envoy.config.cluster.v3.Cluster";
}
- absl::string_view v2_type_url() const override {
- return "envoy.api.v2.Cluster";
- }
- absl::StatusOr<DecodeResult> Decode(const XdsEncodingContext& context,
- absl::string_view serialized_resource,
- bool is_v2) const override;
+ DecodeResult Decode(const XdsResourceType::DecodeContext& context,
+ absl::string_view serialized_resource) const override;
bool AllResourcesRequiredInSotW() const override { return true; }
- void InitUpbSymtab(upb_DefPool* symtab) const override {
+ void InitUpbSymtab(XdsClient*, upb_DefPool* symtab) const override {
envoy_config_cluster_v3_Cluster_getmsgdef(symtab);
envoy_extensions_clusters_aggregate_v3_ClusterConfig_getmsgdef(symtab);
envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_getmsgdef(
@@ -105,4 +133,4 @@ class XdsClusterResourceType
} // namespace grpc_core
-#endif // GRPC_CORE_EXT_XDS_XDS_CLUSTER_H
+#endif // GRPC_SRC_CORE_EXT_XDS_XDS_CLUSTER_H