diff --git a/BUILD b/BUILD
index b56b31470f9..c8c00b095a7 100644
--- a/BUILD
+++ b/BUILD
@@ -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",
diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml
index 4661739ec5e..b4f16357c9d 100644
--- a/build_autogenerated.yaml
+++ b/build_autogenerated.yaml
@@ -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
diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec
index 8a42c509ef1..0c4046e2ba9 100644
--- a/gRPC-C++.podspec
+++ b/gRPC-C++.podspec
@@ -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',
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 2f4761ae343..6878fdca037 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -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',
diff --git a/grpc.gemspec b/grpc.gemspec
index 008a4fbb627..0bae8bac833 100644
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -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 )
diff --git a/package.xml b/package.xml
index 0d3df25549c..537aa359472 100644
--- a/package.xml
+++ b/package.xml
@@ -735,6 +735,7 @@
+
diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
index efe4465c5b0..cffba662576 100644
--- a/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
@@ -72,7 +72,7 @@ class CdsLb : public LoadBalancingPolicy {
ClusterWatcher(RefCountedPtr 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
diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc
index e7d7e769d2b..90f422025ff 100644
--- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc
@@ -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));
}
diff --git a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
index 892d478cd27..820f11a9ce5 100644
--- a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
+++ b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc
@@ -86,7 +86,7 @@ class XdsResolver : public Resolver {
public:
explicit ListenerWatcher(RefCountedPtr 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 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
diff --git a/src/core/ext/xds/xds_client.cc b/src/core/ext/xds/xds_client.cc
index 04b57923e6c..4039622f2ea 100644
--- a/src/core/ext/xds/xds_client.cc
+++ b/src/core/ext/xds/xds_client.cc
@@ -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);
diff --git a/src/core/ext/xds/xds_client.h b/src/core/ext/xds/xds_client.h
index 66fbec26d21..6931a0a3f50 100644
--- a/src/core/ext/xds/xds_client.h
+++ b/src/core/ext/xds/xds_client.h
@@ -51,7 +51,7 @@ class XdsClient : public DualRefCounted {
// XdsResourceType implementation.
class ResourceWatcherInterface : public RefCounted {
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)
diff --git a/src/core/ext/xds/xds_cluster.cc b/src/core/ext/xds/xds_cluster.cc
index 5e7f2662441..db9928fd1a3 100644
--- a/src/core/ext/xds/xds_cluster.cc
+++ b/src/core/ext/xds/xds_cluster.cc
@@ -427,7 +427,7 @@ absl::StatusOr XdsClusterResourceType::Decode(
DecodeResult result;
result.name =
UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(resource));
- auto cluster_data = absl::make_unique();
+ auto cluster_data = absl::make_unique();
grpc_error_handle error =
CdsResourceParse(context, resource, is_v2, &cluster_data->resource);
if (error != GRPC_ERROR_NONE) {
diff --git a/src/core/ext/xds/xds_cluster.h b/src/core/ext/xds/xds_cluster.h
index 4600bfc5f48..a78475324bb 100644
--- a/src/core/ext/xds/xds_cluster.h
+++ b/src/core/ext/xds/xds_cluster.h
@@ -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 {
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(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 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 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(r1)->resource ==
- static_cast(r2)->resource;
- }
-
- std::unique_ptr CopyResource(
- const ResourceData* resource) const override {
- auto* resource_copy = new ClusterData();
- resource_copy->resource =
- static_cast(resource)->resource;
- return std::unique_ptr(resource_copy);
- }
-
bool AllResourcesRequiredInSotW() const override { return true; }
void InitUpbSymtab(upb_symtab* symtab) const override {
diff --git a/src/core/ext/xds/xds_endpoint.cc b/src/core/ext/xds/xds_endpoint.cc
index 3d37c1b0e42..5bf9530cea8 100644
--- a/src/core/ext/xds/xds_endpoint.cc
+++ b/src/core/ext/xds/xds_endpoint.cc
@@ -338,7 +338,7 @@ absl::StatusOr XdsEndpointResourceType::Decode(
DecodeResult result;
result.name = UpbStringToStdString(
envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(resource));
- auto endpoint_data = absl::make_unique();
+ auto endpoint_data = absl::make_unique();
grpc_error_handle error =
EdsResourceParse(context, resource, is_v2, &endpoint_data->resource);
if (error != GRPC_ERROR_NONE) {
diff --git a/src/core/ext/xds/xds_endpoint.h b/src/core/ext/xds/xds_endpoint.h
index d47e263a1d4..06ac4920563 100644
--- a/src/core/ext/xds/xds_endpoint.h
+++ b/src/core/ext/xds/xds_endpoint.h
@@ -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 {
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(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 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 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(r1)->resource ==
- static_cast(r2)->resource;
- }
-
- std::unique_ptr CopyResource(
- const ResourceData* resource) const override {
- auto* resource_copy = new EndpointData();
- resource_copy->resource =
- static_cast(resource)->resource;
- return std::unique_ptr(resource_copy);
- }
-
void InitUpbSymtab(upb_symtab* symtab) const override {
envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(symtab);
}
diff --git a/src/core/ext/xds/xds_listener.cc b/src/core/ext/xds/xds_listener.cc
index 75d65b40d1e..8d797dbd231 100644
--- a/src/core/ext/xds/xds_listener.cc
+++ b/src/core/ext/xds/xds_listener.cc
@@ -997,7 +997,7 @@ absl::StatusOr XdsListenerResourceType::Decode(
DecodeResult result;
result.name =
UpbStringToStdString(envoy_config_listener_v3_Listener_name(resource));
- auto listener_data = absl::make_unique();
+ auto listener_data = absl::make_unique();
grpc_error_handle error =
LdsResourceParse(context, resource, is_v2, &listener_data->resource);
if (error != GRPC_ERROR_NONE) {
diff --git a/src/core/ext/xds/xds_listener.h b/src/core/ext/xds/xds_listener.h
index 151a8aee75d..a8a5635fd56 100644
--- a/src/core/ext/xds/xds_listener.h
+++ b/src/core/ext/xds/xds_listener.h
@@ -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 {
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(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 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 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(r1)->resource ==
- static_cast(r2)->resource;
- }
-
- std::unique_ptr CopyResource(
- const ResourceData* resource) const override {
- auto* resource_copy = new ListenerData();
- resource_copy->resource =
- static_cast(resource)->resource;
- return std::unique_ptr(resource_copy);
- }
-
bool AllResourcesRequiredInSotW() const override { return true; }
void InitUpbSymtab(upb_symtab* symtab) const override {
diff --git a/src/core/ext/xds/xds_resource_type_impl.h b/src/core/ext/xds/xds_resource_type_impl.h
new file mode 100644
index 00000000000..94ebe8edeaa
--- /dev/null
+++ b/src/core/ext/xds/xds_resource_type_impl.h
@@ -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
+
+#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
+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(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 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(r1)->resource ==
+ static_cast(r2)->resource;
+ }
+
+ std::unique_ptr CopyResource(
+ const ResourceData* resource) const override {
+ auto* resource_copy = new ResourceDataSubclass();
+ resource_copy->resource =
+ static_cast(resource)->resource;
+ return std::unique_ptr(resource_copy);
+ }
+};
+
+} // namespace grpc_core
+
+#endif // GRPC_CORE_EXT_XDS_XDS_RESOURCE_TYPE_IMPL_H
diff --git a/src/core/ext/xds/xds_route_config.cc b/src/core/ext/xds/xds_route_config.cc
index 618772c5d6a..fa4c85143f1 100644
--- a/src/core/ext/xds/xds_route_config.cc
+++ b/src/core/ext/xds/xds_route_config.cc
@@ -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();
+ auto route_config_data = absl::make_unique();
grpc_error_handle error = XdsRouteConfigResource::Parse(
context, resource, &route_config_data->resource);
if (error != GRPC_ERROR_NONE) {
diff --git a/src/core/ext/xds/xds_route_config.h b/src/core/ext/xds/xds_route_config.h
index f96a2c0ef2f..73c558e783f 100644
--- a/src/core/ext/xds/xds_route_config.h
+++ b/src/core/ext/xds/xds_route_config.h
@@ -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 {
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(
- 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 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 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(r1)->resource ==
- static_cast(r2)->resource;
- }
-
- std::unique_ptr CopyResource(
- const ResourceData* resource) const override {
- auto* resource_copy = new RouteConfigData();
- resource_copy->resource =
- static_cast(resource)->resource;
- return std::unique_ptr(resource_copy);
- }
-
void InitUpbSymtab(upb_symtab* symtab) const override {
envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab);
}
diff --git a/src/core/ext/xds/xds_server_config_fetcher.cc b/src/core/ext/xds/xds_server_config_fetcher.cc
index 6d0c3d0e6be..5b7bbef1457 100644
--- a/src/core/ext/xds/xds_server_config_fetcher.cc
+++ b/src/core/ext/xds/xds_server_config_fetcher.cc
@@ -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 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,
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index 65164414dd1..7a566cc2e6a 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -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 \
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index a205835de3a..eadf8a934d2 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -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 \