XdsClient: use a templated base class for XdsResourceType implementations (#28279)

* WIP

* introduce XdsResourceType API and change Listener parsing to use it

* converted RouteConfig parsing

* convert cluster and endpoint parsing

* cleanup

* clang-format

* attempt to work around compiler problems

* move XdsResourceType to its own file, and move endpoint code out of XdsApi

* move cluster parsing to its own file

* move route config parsing to its own file

* move listener parsing to its own file

* clang-format

* minor cleanup

* plumbed XdsResourceType throughout XdsClient

* a bit of cleanup

* more cleanup

* construct full resource names before calling XdsApi::CreateAdsRequest()

* remove some unneeded code

* clean up includes and have XdsResourceType initialize the upb symtab

* more cleanup of unnecessary code

* more cleanup

* update comment

* clang-format

* add missing virtual dtor

* fix build

* remove resource-type-specific methods from XdsClient API

* have each resource type register itself upon instantiation

* remove comment

* add missing virtual dtor

* clang-format

* use a templated base class for XdsResourceType implementations

* clang-format
pull/28319/head
Mark D. Roth 3 years ago committed by GitHub
parent b75dc22d7f
commit 9965ece70a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 1
      build_autogenerated.yaml
  3. 2
      gRPC-C++.podspec
  4. 2
      gRPC-Core.podspec
  5. 1
      grpc.gemspec
  6. 1
      package.xml
  7. 2
      src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
  8. 6
      src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc
  9. 4
      src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
  10. 4
      src/core/ext/xds/xds_client.cc
  11. 2
      src/core/ext/xds/xds_client.h
  12. 2
      src/core/ext/xds/xds_cluster.cc
  13. 55
      src/core/ext/xds/xds_cluster.h
  14. 2
      src/core/ext/xds/xds_endpoint.cc
  15. 55
      src/core/ext/xds/xds_endpoint.h
  16. 2
      src/core/ext/xds/xds_listener.cc
  17. 54
      src/core/ext/xds/xds_listener.h
  18. 87
      src/core/ext/xds/xds_resource_type_impl.h
  19. 2
      src/core/ext/xds/xds_route_config.cc
  20. 57
      src/core/ext/xds/xds_route_config.h
  21. 8
      src/core/ext/xds/xds_server_config_fetcher.cc
  22. 1
      tools/doxygen/Doxyfile.c++.internal
  23. 1
      tools/doxygen/Doxyfile.core.internal

@ -2645,6 +2645,7 @@ grpc_cc_library(
"src/core/ext/xds/xds_http_filters.h",
"src/core/ext/xds/xds_listener.h",
"src/core/ext/xds/xds_resource_type.h",
"src/core/ext/xds/xds_resource_type_impl.h",
"src/core/ext/xds/xds_route_config.h",
"src/core/ext/xds/xds_routing.h",
"src/core/lib/security/credentials/xds/xds_credentials.h",

@ -728,6 +728,7 @@ libs:
- src/core/ext/xds/xds_http_filters.h
- src/core/ext/xds/xds_listener.h
- src/core/ext/xds/xds_resource_type.h
- src/core/ext/xds/xds_resource_type_impl.h
- src/core/ext/xds/xds_route_config.h
- src/core/ext/xds/xds_routing.h
- src/core/lib/address_utils/parse_address.h

2
gRPC-C++.podspec generated

@ -565,6 +565,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_http_filters.h',
'src/core/ext/xds/xds_listener.h',
'src/core/ext/xds/xds_resource_type.h',
'src/core/ext/xds/xds_resource_type_impl.h',
'src/core/ext/xds/xds_route_config.h',
'src/core/ext/xds/xds_routing.h',
'src/core/lib/address_utils/parse_address.h',
@ -1288,6 +1289,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_http_filters.h',
'src/core/ext/xds/xds_listener.h',
'src/core/ext/xds/xds_resource_type.h',
'src/core/ext/xds/xds_resource_type_impl.h',
'src/core/ext/xds/xds_route_config.h',
'src/core/ext/xds/xds_routing.h',
'src/core/lib/address_utils/parse_address.h',

2
gRPC-Core.podspec generated

@ -836,6 +836,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_listener.h',
'src/core/ext/xds/xds_resource_type.cc',
'src/core/ext/xds/xds_resource_type.h',
'src/core/ext/xds/xds_resource_type_impl.h',
'src/core/ext/xds/xds_route_config.cc',
'src/core/ext/xds/xds_route_config.h',
'src/core/ext/xds/xds_routing.cc',
@ -1825,6 +1826,7 @@ Pod::Spec.new do |s|
'src/core/ext/xds/xds_http_filters.h',
'src/core/ext/xds/xds_listener.h',
'src/core/ext/xds/xds_resource_type.h',
'src/core/ext/xds/xds_resource_type_impl.h',
'src/core/ext/xds/xds_route_config.h',
'src/core/ext/xds/xds_routing.h',
'src/core/lib/address_utils/parse_address.h',

1
grpc.gemspec generated

@ -755,6 +755,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/xds/xds_listener.h )
s.files += %w( src/core/ext/xds/xds_resource_type.cc )
s.files += %w( src/core/ext/xds/xds_resource_type.h )
s.files += %w( src/core/ext/xds/xds_resource_type_impl.h )
s.files += %w( src/core/ext/xds/xds_route_config.cc )
s.files += %w( src/core/ext/xds/xds_route_config.h )
s.files += %w( src/core/ext/xds/xds_routing.cc )

1
package.xml generated

@ -735,6 +735,7 @@
<file baseinstalldir="/" name="src/core/ext/xds/xds_listener.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_resource_type.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_resource_type.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_resource_type_impl.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_route_config.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_route_config.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/xds/xds_routing.cc" role="src" />

@ -72,7 +72,7 @@ class CdsLb : public LoadBalancingPolicy {
ClusterWatcher(RefCountedPtr<CdsLb> parent, std::string name)
: parent_(std::move(parent)), name_(std::move(name)) {}
void OnClusterChanged(XdsClusterResource cluster_data) override {
void OnResourceChanged(XdsClusterResource cluster_data) override {
Ref().release(); // Ref held by lambda
parent_->work_serializer()->Run(
// TODO(roth): When we move to C++14, capture cluster_data with

@ -174,13 +174,13 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
~EndpointWatcher() override {
discovery_mechanism_.reset(DEBUG_LOCATION, "EndpointWatcher");
}
void OnEndpointChanged(XdsEndpointResource update) override {
void OnResourceChanged(XdsEndpointResource update) override {
Ref().release(); // ref held by callback
discovery_mechanism_->parent()->work_serializer()->Run(
// TODO(yashykt): When we move to C++14, capture update with
// std::move
[this, update]() mutable {
OnEndpointChangedHelper(std::move(update));
OnResourceChangedHelper(std::move(update));
Unref();
},
DEBUG_LOCATION);
@ -208,7 +208,7 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
// Code accessing protected methods of `DiscoveryMechanism` need to be
// in methods of this class rather than in lambdas to work around an MSVC
// bug.
void OnEndpointChangedHelper(XdsEndpointResource update) {
void OnResourceChangedHelper(XdsEndpointResource update) {
discovery_mechanism_->parent()->OnEndpointChanged(
discovery_mechanism_->index(), std::move(update));
}

@ -86,7 +86,7 @@ class XdsResolver : public Resolver {
public:
explicit ListenerWatcher(RefCountedPtr<XdsResolver> resolver)
: resolver_(std::move(resolver)) {}
void OnListenerChanged(XdsListenerResource listener) override {
void OnResourceChanged(XdsListenerResource listener) override {
Ref().release(); // ref held by lambda
resolver_->work_serializer_->Run(
// TODO(yashykt): When we move to C++14, capture listener with
@ -125,7 +125,7 @@ class XdsResolver : public Resolver {
public:
explicit RouteConfigWatcher(RefCountedPtr<XdsResolver> resolver)
: resolver_(std::move(resolver)) {}
void OnRouteConfigChanged(XdsRouteConfigResource route_config) override {
void OnResourceChanged(XdsRouteConfigResource route_config) override {
Ref().release(); // ref held by lambda
resolver_->work_serializer_->Run(
// TODO(yashykt): When we move to C++14, capture route_config with

@ -887,7 +887,7 @@ void XdsClient::ChannelState::AdsCallState::AdsResponseParser::ParseResource(
[watchers_list, value]()
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&xds_client()->work_serializer_) {
for (const auto& p : watchers_list) {
p.first->OnResourceChanged(value);
p.first->OnGenericResourceChanged(value);
}
delete value;
},
@ -1870,7 +1870,7 @@ void XdsClient::WatchResource(const XdsResourceType* type,
auto* value = type->CopyResource(resource_state.resource.get()).release();
work_serializer_.Schedule(
[watcher, value]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(&work_serializer_) {
watcher->OnResourceChanged(value);
watcher->OnGenericResourceChanged(value);
delete value;
},
DEBUG_LOCATION);

@ -51,7 +51,7 @@ class XdsClient : public DualRefCounted<XdsClient> {
// XdsResourceType implementation.
class ResourceWatcherInterface : public RefCounted<ResourceWatcherInterface> {
public:
virtual void OnResourceChanged(
virtual void OnGenericResourceChanged(
const XdsResourceType::ResourceData* resource)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(&work_serializer_) = 0;
virtual void OnError(grpc_error_handle error)

@ -427,7 +427,7 @@ absl::StatusOr<XdsResourceType::DecodeResult> XdsClusterResourceType::Decode(
DecodeResult result;
result.name =
UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(resource));
auto cluster_data = absl::make_unique<ClusterData>();
auto cluster_data = absl::make_unique<ResourceDataSubclass>();
grpc_error_handle error =
CdsResourceParse(context, resource, is_v2, &cluster_data->resource);
if (error != GRPC_ERROR_NONE) {

@ -29,7 +29,7 @@
#include "src/core/ext/xds/xds_client.h"
#include "src/core/ext/xds/xds_common_types.h"
#include "src/core/ext/xds/xds_resource_type.h"
#include "src/core/ext/xds/xds_resource_type_impl.h"
namespace grpc_core {
@ -82,31 +82,9 @@ struct XdsClusterResource {
std::string ToString() const;
};
class XdsClusterResourceType : public XdsResourceType {
class XdsClusterResourceType
: public XdsResourceTypeImpl<XdsClusterResourceType, XdsClusterResource> {
public:
struct ClusterData : public ResourceData {
XdsClusterResource resource;
};
class WatcherInterface : public XdsClient::ResourceWatcherInterface {
public:
virtual void OnClusterChanged(XdsClusterResource cluster_data) = 0;
private:
void OnResourceChanged(
const XdsResourceType::ResourceData* resource) override {
OnClusterChanged(
static_cast<const XdsClusterResourceType::ClusterData*>(resource)
->resource);
}
};
static const XdsClusterResourceType* Get() {
static const XdsClusterResourceType* g_instance =
new XdsClusterResourceType();
return g_instance;
}
absl::string_view type_url() const override {
return "envoy.config.cluster.v3.Cluster";
}
@ -114,37 +92,10 @@ class XdsClusterResourceType : public XdsResourceType {
return "envoy.api.v2.Cluster";
}
static void StartWatch(XdsClient* xds_client, absl::string_view resource_name,
RefCountedPtr<WatcherInterface> watcher) {
xds_client->WatchResource(Get(), resource_name, std::move(watcher));
}
static void CancelWatch(XdsClient* xds_client,
absl::string_view resource_name,
WatcherInterface* watcher,
bool delay_unsubscription = false) {
xds_client->CancelResourceWatch(Get(), resource_name, watcher,
delay_unsubscription);
}
absl::StatusOr<DecodeResult> Decode(const XdsEncodingContext& context,
absl::string_view serialized_resource,
bool is_v2) const override;
bool ResourcesEqual(const ResourceData* r1,
const ResourceData* r2) const override {
return static_cast<const ClusterData*>(r1)->resource ==
static_cast<const ClusterData*>(r2)->resource;
}
std::unique_ptr<ResourceData> CopyResource(
const ResourceData* resource) const override {
auto* resource_copy = new ClusterData();
resource_copy->resource =
static_cast<const ClusterData*>(resource)->resource;
return std::unique_ptr<ResourceData>(resource_copy);
}
bool AllResourcesRequiredInSotW() const override { return true; }
void InitUpbSymtab(upb_symtab* symtab) const override {

@ -338,7 +338,7 @@ absl::StatusOr<XdsResourceType::DecodeResult> XdsEndpointResourceType::Decode(
DecodeResult result;
result.name = UpbStringToStdString(
envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(resource));
auto endpoint_data = absl::make_unique<EndpointData>();
auto endpoint_data = absl::make_unique<ResourceDataSubclass>();
grpc_error_handle error =
EdsResourceParse(context, resource, is_v2, &endpoint_data->resource);
if (error != GRPC_ERROR_NONE) {

@ -29,7 +29,7 @@
#include "src/core/ext/filters/client_channel/server_address.h"
#include "src/core/ext/xds/xds_client.h"
#include "src/core/ext/xds/xds_client_stats.h"
#include "src/core/ext/xds/xds_resource_type.h"
#include "src/core/ext/xds/xds_resource_type_impl.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
namespace grpc_core {
@ -111,31 +111,9 @@ struct XdsEndpointResource {
std::string ToString() const;
};
class XdsEndpointResourceType : public XdsResourceType {
class XdsEndpointResourceType
: public XdsResourceTypeImpl<XdsEndpointResourceType, XdsEndpointResource> {
public:
struct EndpointData : public ResourceData {
XdsEndpointResource resource;
};
class WatcherInterface : public XdsClient::ResourceWatcherInterface {
public:
virtual void OnEndpointChanged(XdsEndpointResource update) = 0;
private:
void OnResourceChanged(
const XdsResourceType::ResourceData* resource) override {
OnEndpointChanged(
static_cast<const XdsEndpointResourceType::EndpointData*>(resource)
->resource);
}
};
static const XdsEndpointResourceType* Get() {
static const XdsEndpointResourceType* g_instance =
new XdsEndpointResourceType();
return g_instance;
}
absl::string_view type_url() const override {
return "envoy.config.endpoint.v3.ClusterLoadAssignment";
}
@ -143,37 +121,10 @@ class XdsEndpointResourceType : public XdsResourceType {
return "envoy.api.v2.ClusterLoadAssignment";
}
static void StartWatch(XdsClient* xds_client, absl::string_view resource_name,
RefCountedPtr<WatcherInterface> watcher) {
xds_client->WatchResource(Get(), resource_name, std::move(watcher));
}
static void CancelWatch(XdsClient* xds_client,
absl::string_view resource_name,
WatcherInterface* watcher,
bool delay_unsubscription = false) {
xds_client->CancelResourceWatch(Get(), resource_name, watcher,
delay_unsubscription);
}
absl::StatusOr<DecodeResult> Decode(const XdsEncodingContext& context,
absl::string_view serialized_resource,
bool is_v2) const override;
bool ResourcesEqual(const ResourceData* r1,
const ResourceData* r2) const override {
return static_cast<const EndpointData*>(r1)->resource ==
static_cast<const EndpointData*>(r2)->resource;
}
std::unique_ptr<ResourceData> CopyResource(
const ResourceData* resource) const override {
auto* resource_copy = new EndpointData();
resource_copy->resource =
static_cast<const EndpointData*>(resource)->resource;
return std::unique_ptr<ResourceData>(resource_copy);
}
void InitUpbSymtab(upb_symtab* symtab) const override {
envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(symtab);
}

@ -997,7 +997,7 @@ absl::StatusOr<XdsResourceType::DecodeResult> XdsListenerResourceType::Decode(
DecodeResult result;
result.name =
UpbStringToStdString(envoy_config_listener_v3_Listener_name(resource));
auto listener_data = absl::make_unique<ListenerData>();
auto listener_data = absl::make_unique<ResourceDataSubclass>();
grpc_error_handle error =
LdsResourceParse(context, resource, is_v2, &listener_data->resource);
if (error != GRPC_ERROR_NONE) {

@ -33,6 +33,7 @@
#include "src/core/ext/xds/xds_client.h"
#include "src/core/ext/xds/xds_common_types.h"
#include "src/core/ext/xds/xds_http_filters.h"
#include "src/core/ext/xds/xds_resource_type_impl.h"
#include "src/core/ext/xds/xds_route_config.h"
namespace grpc_core {
@ -190,31 +191,9 @@ struct XdsListenerResource {
std::string ToString() const;
};
class XdsListenerResourceType : public XdsResourceType {
class XdsListenerResourceType
: public XdsResourceTypeImpl<XdsListenerResourceType, XdsListenerResource> {
public:
struct ListenerData : public ResourceData {
XdsListenerResource resource;
};
class WatcherInterface : public XdsClient::ResourceWatcherInterface {
public:
virtual void OnListenerChanged(XdsListenerResource listener) = 0;
private:
void OnResourceChanged(
const XdsResourceType::ResourceData* resource) override {
OnListenerChanged(
static_cast<const XdsListenerResourceType::ListenerData*>(resource)
->resource);
}
};
static const XdsListenerResourceType* Get() {
static const XdsListenerResourceType* g_instance =
new XdsListenerResourceType();
return g_instance;
}
absl::string_view type_url() const override {
return "envoy.config.listener.v3.Listener";
}
@ -222,37 +201,10 @@ class XdsListenerResourceType : public XdsResourceType {
return "envoy.api.v2.Listener";
}
static void StartWatch(XdsClient* xds_client, absl::string_view resource_name,
RefCountedPtr<WatcherInterface> watcher) {
xds_client->WatchResource(Get(), resource_name, std::move(watcher));
}
static void CancelWatch(XdsClient* xds_client,
absl::string_view resource_name,
WatcherInterface* watcher,
bool delay_unsubscription = false) {
xds_client->CancelResourceWatch(Get(), resource_name, watcher,
delay_unsubscription);
}
absl::StatusOr<DecodeResult> Decode(const XdsEncodingContext& context,
absl::string_view serialized_resource,
bool is_v2) const override;
bool ResourcesEqual(const ResourceData* r1,
const ResourceData* r2) const override {
return static_cast<const ListenerData*>(r1)->resource ==
static_cast<const ListenerData*>(r2)->resource;
}
std::unique_ptr<ResourceData> CopyResource(
const ResourceData* resource) const override {
auto* resource_copy = new ListenerData();
resource_copy->resource =
static_cast<const ListenerData*>(resource)->resource;
return std::unique_ptr<ResourceData>(resource_copy);
}
bool AllResourcesRequiredInSotW() const override { return true; }
void InitUpbSymtab(upb_symtab* symtab) const override {

@ -0,0 +1,87 @@
//
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <grpc/support/port_platform.h>
#include "src/core/ext/xds/xds_client.h"
#include "src/core/ext/xds/xds_resource_type.h"
#ifndef GRPC_CORE_EXT_XDS_XDS_RESOURCE_TYPE_IMPL_H
#define GRPC_CORE_EXT_XDS_XDS_RESOURCE_TYPE_IMPL_H
namespace grpc_core {
// Base class for XdsResourceType implementations.
// Handles all down-casting logic for a particular resource type struct.
template <typename Subclass, typename ResourceTypeStruct>
class XdsResourceTypeImpl : public XdsResourceType {
public:
struct ResourceDataSubclass : public ResourceData {
ResourceTypeStruct resource;
};
// XdsClient watcher that handles down-casting.
class WatcherInterface : public XdsClient::ResourceWatcherInterface {
public:
virtual void OnResourceChanged(ResourceTypeStruct listener) = 0;
private:
// Get result from XdsClient generic watcher interface, perform
// down-casting, and invoke the caller's OnListenerChanged() method.
void OnGenericResourceChanged(
const XdsResourceType::ResourceData* resource) override {
OnResourceChanged(
static_cast<const ResourceDataSubclass*>(resource)->resource);
}
};
static const Subclass* Get() {
static const Subclass* g_instance = new Subclass();
return g_instance;
}
// Convenient wrappers around XdsClient generic watcher API that provide
// type-safety.
static void StartWatch(XdsClient* xds_client, absl::string_view resource_name,
RefCountedPtr<WatcherInterface> watcher) {
xds_client->WatchResource(Get(), resource_name, std::move(watcher));
}
static void CancelWatch(XdsClient* xds_client,
absl::string_view resource_name,
WatcherInterface* watcher,
bool delay_unsubscription = false) {
xds_client->CancelResourceWatch(Get(), resource_name, watcher,
delay_unsubscription);
}
bool ResourcesEqual(const ResourceData* r1,
const ResourceData* r2) const override {
return static_cast<const ResourceDataSubclass*>(r1)->resource ==
static_cast<const ResourceDataSubclass*>(r2)->resource;
}
std::unique_ptr<ResourceData> CopyResource(
const ResourceData* resource) const override {
auto* resource_copy = new ResourceDataSubclass();
resource_copy->resource =
static_cast<const ResourceDataSubclass*>(resource)->resource;
return std::unique_ptr<ResourceData>(resource_copy);
}
};
} // namespace grpc_core
#endif // GRPC_CORE_EXT_XDS_XDS_RESOURCE_TYPE_IMPL_H

@ -968,7 +968,7 @@ XdsRouteConfigResourceType::Decode(const XdsEncodingContext& context,
DecodeResult result;
result.name = UpbStringToStdString(
envoy_config_route_v3_RouteConfiguration_name(resource));
auto route_config_data = absl::make_unique<RouteConfigData>();
auto route_config_data = absl::make_unique<ResourceDataSubclass>();
grpc_error_handle error = XdsRouteConfigResource::Parse(
context, resource, &route_config_data->resource);
if (error != GRPC_ERROR_NONE) {

@ -32,7 +32,7 @@
#include "src/core/ext/xds/xds_client.h"
#include "src/core/ext/xds/xds_common_types.h"
#include "src/core/ext/xds/xds_http_filters.h"
#include "src/core/ext/xds/xds_resource_type.h"
#include "src/core/ext/xds/xds_resource_type_impl.h"
#include "src/core/lib/channel/status_util.h"
#include "src/core/lib/matchers/matchers.h"
@ -190,32 +190,10 @@ struct XdsRouteConfigResource {
XdsRouteConfigResource* rds_update);
};
class XdsRouteConfigResourceType : public XdsResourceType {
class XdsRouteConfigResourceType
: public XdsResourceTypeImpl<XdsRouteConfigResourceType,
XdsRouteConfigResource> {
public:
struct RouteConfigData : public ResourceData {
XdsRouteConfigResource resource;
};
class WatcherInterface : public XdsClient::ResourceWatcherInterface {
public:
virtual void OnRouteConfigChanged(XdsRouteConfigResource route_config) = 0;
private:
void OnResourceChanged(
const XdsResourceType::ResourceData* resource) override {
OnRouteConfigChanged(
static_cast<const XdsRouteConfigResourceType::RouteConfigData*>(
resource)
->resource);
}
};
static const XdsRouteConfigResourceType* Get() {
static const XdsRouteConfigResourceType* g_instance =
new XdsRouteConfigResourceType();
return g_instance;
}
absl::string_view type_url() const override {
return "envoy.config.route.v3.RouteConfiguration";
}
@ -223,37 +201,10 @@ class XdsRouteConfigResourceType : public XdsResourceType {
return "envoy.api.v2.RouteConfiguration";
}
static void StartWatch(XdsClient* xds_client, absl::string_view resource_name,
RefCountedPtr<WatcherInterface> watcher) {
xds_client->WatchResource(Get(), resource_name, std::move(watcher));
}
static void CancelWatch(XdsClient* xds_client,
absl::string_view resource_name,
WatcherInterface* watcher,
bool delay_unsubscription = false) {
xds_client->CancelResourceWatch(Get(), resource_name, watcher,
delay_unsubscription);
}
absl::StatusOr<DecodeResult> Decode(const XdsEncodingContext& context,
absl::string_view serialized_resource,
bool /*is_v2*/) const override;
bool ResourcesEqual(const ResourceData* r1,
const ResourceData* r2) const override {
return static_cast<const RouteConfigData*>(r1)->resource ==
static_cast<const RouteConfigData*>(r2)->resource;
}
std::unique_ptr<ResourceData> CopyResource(
const ResourceData* resource) const override {
auto* resource_copy = new RouteConfigData();
resource_copy->resource =
static_cast<const RouteConfigData*>(resource)->resource;
return std::unique_ptr<ResourceData>(resource_copy);
}
void InitUpbSymtab(upb_symtab* symtab) const override {
envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab);
}

@ -96,7 +96,7 @@ class XdsServerConfigFetcher::ListenerWatcher
grpc_server_xds_status_notifier serving_status_notifier,
std::string listening_address);
void OnListenerChanged(XdsListenerResource listener) override;
void OnResourceChanged(XdsListenerResource listener) override;
void OnError(grpc_error_handle error) override;
@ -227,7 +227,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
: resource_name_(std::move(resource_name)),
filter_chain_match_manager_(std::move(filter_chain_match_manager)) {}
void OnRouteConfigChanged(XdsRouteConfigResource route_config) override {
void OnResourceChanged(XdsRouteConfigResource route_config) override {
filter_chain_match_manager_->OnRouteConfigChanged(resource_name_,
std::move(route_config));
}
@ -389,7 +389,7 @@ class XdsServerConfigFetcher::ListenerWatcher::FilterChainMatchManager::
RefCountedPtr<DynamicXdsServerConfigSelectorProvider> parent)
: parent_(std::move(parent)) {}
void OnRouteConfigChanged(XdsRouteConfigResource route_config) override {
void OnResourceChanged(XdsRouteConfigResource route_config) override {
parent_->OnRouteConfigChanged(std::move(route_config));
}
@ -461,7 +461,7 @@ XdsServerConfigFetcher::ListenerWatcher::ListenerWatcher(
serving_status_notifier_(serving_status_notifier),
listening_address_(std::move(listening_address)) {}
void XdsServerConfigFetcher::ListenerWatcher::OnListenerChanged(
void XdsServerConfigFetcher::ListenerWatcher::OnResourceChanged(
XdsListenerResource listener) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_server_config_fetcher_trace)) {
gpr_log(GPR_INFO,

@ -1734,6 +1734,7 @@ src/core/ext/xds/xds_listener.cc \
src/core/ext/xds/xds_listener.h \
src/core/ext/xds/xds_resource_type.cc \
src/core/ext/xds/xds_resource_type.h \
src/core/ext/xds/xds_resource_type_impl.h \
src/core/ext/xds/xds_route_config.cc \
src/core/ext/xds/xds_route_config.h \
src/core/ext/xds/xds_routing.cc \

@ -1528,6 +1528,7 @@ src/core/ext/xds/xds_listener.cc \
src/core/ext/xds/xds_listener.h \
src/core/ext/xds/xds_resource_type.cc \
src/core/ext/xds/xds_resource_type.h \
src/core/ext/xds/xds_resource_type_impl.h \
src/core/ext/xds/xds_route_config.cc \
src/core/ext/xds/xds_route_config.h \
src/core/ext/xds/xds_routing.cc \

Loading…
Cancel
Save