diff --git a/include/envoy/config/BUILD b/include/envoy/config/BUILD index cd909d922ddb..50fca3a73007 100644 --- a/include/envoy/config/BUILD +++ b/include/envoy/config/BUILD @@ -53,6 +53,7 @@ envoy_cc_library( hdrs = ["subscription.h"], deps = [ "//include/envoy/stats:stats_macros", + "//source/common/config:api_type_oracle_lib", "//source/common/protobuf", "@envoy_api//envoy/service/discovery/v3:pkg_cc_proto", ], @@ -75,13 +76,3 @@ envoy_cc_library( "//source/common/protobuf", ], ) - -envoy_cc_library( - name = "discovery_service_base_interface", - hdrs = ["discovery_service_base.h"], - deps = [ - ":subscription_interface", - "//source/common/config:api_type_oracle_lib", - "//source/common/protobuf", - ], -) diff --git a/include/envoy/config/discovery_service_base.h b/include/envoy/config/discovery_service_base.h deleted file mode 100644 index 52ae80e127c6..000000000000 --- a/include/envoy/config/discovery_service_base.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include - -#include "envoy/config/discovery_service_base.h" -#include "envoy/config/subscription.h" - -#include "common/config/api_type_oracle.h" - -namespace Envoy { -namespace Config { -template struct SubscriptionBase : public Config::SubscriptionCallbacks { - static std::string getResourceName(envoy::config::core::v3::ApiVersion resource_api_version) { - switch (resource_api_version) { - case envoy::config::core::v3::ApiVersion::AUTO: - case envoy::config::core::v3::ApiVersion::V2: - return ApiTypeOracle::getEarlierVersionMessageTypeName(Current().GetDescriptor()->full_name()) - .value(); - case envoy::config::core::v3::ApiVersion::V3: - return Current().GetDescriptor()->full_name(); - default: - NOT_REACHED_GCOVR_EXCL_LINE; - } - } -}; - -} // namespace Config -} // namespace Envoy \ No newline at end of file diff --git a/source/common/config/BUILD b/source/common/config/BUILD index 082f1cc30f50..aa386f3c5d66 100644 --- a/source/common/config/BUILD +++ b/source/common/config/BUILD @@ -251,6 +251,16 @@ envoy_cc_library( ], ) +envoy_cc_library( + name = "resource_name_lib", + hdrs = ["resource_name.h"], + deps = [ + ":api_type_oracle_lib", + "//source/common/common:assert_lib", + "@envoy_api//envoy/config/core/v3:pkg_cc_proto", + ], +) + envoy_cc_library( name = "resources_lib", hdrs = ["resources.h"], @@ -361,6 +371,15 @@ envoy_cc_library( ], ) +envoy_cc_library( + name = "subscription_base_interface", + hdrs = ["subscription_base.h"], + deps = [ + ":resource_name_lib", + "//include/envoy/config:subscription_interface", + ], +) + envoy_cc_library( name = "well_known_names", srcs = ["well_known_names.cc"], diff --git a/source/common/config/grpc_mux_impl.cc b/source/common/config/grpc_mux_impl.cc index c72bb7062d0e..1e495a2a7f94 100644 --- a/source/common/config/grpc_mux_impl.cc +++ b/source/common/config/grpc_mux_impl.cc @@ -244,4 +244,4 @@ void GrpcMuxImpl::drainRequests() { } } // namespace Config -} // namespace Envoy +} // namespace Envoy \ No newline at end of file diff --git a/source/common/config/resource_name.h b/source/common/config/resource_name.h new file mode 100644 index 000000000000..b21a7d47d710 --- /dev/null +++ b/source/common/config/resource_name.h @@ -0,0 +1,61 @@ +#pragma once + +#include +#include + +#include "envoy/config/core/v3/config_source.pb.h" + +#include "common/common/assert.h" +#include "common/config/api_type_oracle.h" + +namespace Envoy { +namespace Config { + +/** + * Get resource name from api type and version. + */ +template +std::string getResourceName(envoy::config::core::v3::ApiVersion resource_api_version) { + switch (resource_api_version) { + case envoy::config::core::v3::ApiVersion::AUTO: + case envoy::config::core::v3::ApiVersion::V2: + return ApiTypeOracle::getEarlierVersionMessageTypeName(Current().GetDescriptor()->full_name()) + .value(); + case envoy::config::core::v3::ApiVersion::V3: + return Current().GetDescriptor()->full_name(); + default: + NOT_REACHED_GCOVR_EXCL_LINE; + } +} + +/** + * Get type url from api type and version. + */ +template +std::string getTypeUrl(envoy::config::core::v3::ApiVersion resource_api_version) { + return "type.googleapis.com/" + getResourceName(resource_api_version); +} + +/** + * get all version resource names. + */ +template std::vector getAllVersionResourceNames() { + return std::vector{ + Current().GetDescriptor()->full_name(), + ApiTypeOracle::getEarlierVersionMessageTypeName(Current().GetDescriptor()->full_name()) + .value()}; +} + +/** + * get all version type urls. + */ +template std::vector getAllVersionTypeUrls() { + auto resource_names = getAllVersionResourceNames(); + for (auto&& resource_name : resource_names) { + resource_name = "type.googleapis.com/" + resource_name; + } + return resource_names; +} + +} // namespace Config +} // namespace Envoy diff --git a/source/common/config/subscription_base.h b/source/common/config/subscription_base.h new file mode 100644 index 000000000000..dd5686f2ffaf --- /dev/null +++ b/source/common/config/subscription_base.h @@ -0,0 +1,24 @@ +#pragma once + +#include "envoy/config/subscription.h" + +#include "common/config/resource_name.h" + +namespace Envoy { +namespace Config { + +template struct SubscriptionBase : public Config::SubscriptionCallbacks { +public: + SubscriptionBase(const envoy::config::core::v3::ApiVersion api_version) + : api_version_(api_version) {} + + std::string getResourceName() const { + return Envoy::Config::getResourceName(api_version_); + } + +private: + const envoy::config::core::v3::ApiVersion api_version_; +}; + +} // namespace Config +} // namespace Envoy \ No newline at end of file diff --git a/source/common/config/utility.cc b/source/common/config/utility.cc index 7acd462ce677..93a5c9035930 100644 --- a/source/common/config/utility.cc +++ b/source/common/config/utility.cc @@ -16,7 +16,6 @@ #include "common/common/hex.h" #include "common/common/utility.h" #include "common/config/api_type_oracle.h" -#include "common/config/resources.h" #include "common/config/version_converter.h" #include "common/config/well_known_names.h" #include "common/protobuf/protobuf.h" diff --git a/source/common/router/BUILD b/source/common/router/BUILD index f237a458d157..a3203e5651f4 100644 --- a/source/common/router/BUILD +++ b/source/common/router/BUILD @@ -123,7 +123,6 @@ envoy_cc_library( hdrs = ["vhds.h"], deps = [ ":config_lib", - "//include/envoy/config:discovery_service_base_interface", "//include/envoy/config:subscription_interface", "//include/envoy/http:codes_interface", "//include/envoy/local_info:local_info_interface", @@ -135,6 +134,7 @@ envoy_cc_library( "//source/common/common:assert_lib", "//source/common/common:minimal_logger_lib", "//source/common/config:api_version_lib", + "//source/common/config:subscription_base_interface", "//source/common/config:utility_lib", "//source/common/init:target_lib", "//source/common/protobuf:utility_lib", @@ -152,7 +152,6 @@ envoy_cc_library( hdrs = ["rds_impl.h"], deps = [ ":config_lib", - "//include/envoy/config:discovery_service_base_interface", "//include/envoy/config:subscription_interface", "//include/envoy/http:codes_interface", "//include/envoy/local_info:local_info_interface", @@ -167,6 +166,7 @@ envoy_cc_library( "//source/common/common:cleanup_lib", "//source/common/common:minimal_logger_lib", "//source/common/config:api_version_lib", + "//source/common/config:subscription_base_interface", "//source/common/config:subscription_factory_lib", "//source/common/config:utility_lib", "//source/common/config:version_converter_lib", @@ -210,7 +210,6 @@ envoy_cc_library( ":rds_lib", ":scoped_config_lib", "//include/envoy/config:config_provider_interface", - "//include/envoy/config:discovery_service_base_interface", "//include/envoy/config:subscription_interface", "//include/envoy/router:route_config_provider_manager_interface", "//include/envoy/stats:stats_interface", @@ -219,6 +218,7 @@ envoy_cc_library( "//source/common/common:minimal_logger_lib", "//source/common/config:api_version_lib", "//source/common/config:config_provider_lib", + "//source/common/config:subscription_base_interface", "//source/common/config:version_converter_lib", "//source/common/init:manager_lib", "//source/common/init:watcher_lib", diff --git a/source/common/router/rds_impl.cc b/source/common/router/rds_impl.cc index a52fc43a25eb..11f45c683dd3 100644 --- a/source/common/router/rds_impl.cc +++ b/source/common/router/rds_impl.cc @@ -68,7 +68,9 @@ RdsRouteConfigSubscription::RdsRouteConfigSubscription( const uint64_t manager_identifier, Server::Configuration::ServerFactoryContext& factory_context, const std::string& stat_prefix, Envoy::Router::RouteConfigProviderManagerImpl& route_config_provider_manager) - : route_config_name_(rds.route_config_name()), factory_context_(factory_context), + : Envoy::Config::SubscriptionBase( + rds.config_source().resource_api_version()), + route_config_name_(rds.route_config_name()), factory_context_(factory_context), validator_(factory_context.messageValidationContext().dynamicValidationVisitor()), parent_init_target_(fmt::format("RdsRouteConfigSubscription init {}", route_config_name_), [this]() { local_init_manager_.initialize(local_init_watcher_); }), @@ -82,7 +84,7 @@ RdsRouteConfigSubscription::RdsRouteConfigSubscription( stat_prefix_(stat_prefix), stats_({ALL_RDS_STATS(POOL_COUNTER(*scope_))}), route_config_provider_manager_(route_config_provider_manager), manager_identifier_(manager_identifier) { - const auto resource_name = getResourceName(rds.config_source().resource_api_version()); + const auto resource_name = getResourceName(); subscription_ = factory_context.clusterManager().subscriptionFactory().subscriptionFromConfigSource( rds.config_source(), Grpc::Common::typeUrl(resource_name), *scope_, *this); diff --git a/source/common/router/rds_impl.h b/source/common/router/rds_impl.h index 09d73ab38048..5481e3398064 100644 --- a/source/common/router/rds_impl.h +++ b/source/common/router/rds_impl.h @@ -27,7 +27,6 @@ #include "common/common/callback_impl.h" #include "common/common/cleanup.h" #include "common/common/logger.h" -#include "common/config/resources.h" #include "common/init/manager_impl.h" #include "common/init/target_impl.h" #include "common/init/watcher_impl.h" diff --git a/source/common/router/scoped_rds.cc b/source/common/router/scoped_rds.cc index a75e81e08fd0..89ec116125eb 100644 --- a/source/common/router/scoped_rds.cc +++ b/source/common/router/scoped_rds.cc @@ -99,13 +99,15 @@ ScopedRdsConfigSubscription::ScopedRdsConfigSubscription( ScopedRoutesConfigProviderManager& config_provider_manager) : DeltaConfigSubscriptionInstance("SRDS", manager_identifier, config_provider_manager, factory_context), + Envoy::Config::SubscriptionBase( + rds_config_source.resource_api_version()), factory_context_(factory_context), name_(name), scope_key_builder_(scope_key_builder), scope_(factory_context.scope().createScope(stat_prefix + "scoped_rds." + name + ".")), stats_({ALL_SCOPED_RDS_STATS(POOL_COUNTER(*scope_))}), rds_config_source_(std::move(rds_config_source)), validation_visitor_(factory_context.messageValidationContext().dynamicValidationVisitor()), stat_prefix_(stat_prefix), route_config_provider_manager_(route_config_provider_manager) { - const auto resource_name = getResourceName(rds_config_source_.resource_api_version()); + const auto resource_name = getResourceName(); subscription_ = factory_context.clusterManager().subscriptionFactory().subscriptionFromConfigSource( scoped_rds.scoped_rds_config_source(), Grpc::Common::typeUrl(resource_name), *scope_, diff --git a/source/common/router/scoped_rds.h b/source/common/router/scoped_rds.h index 9b57aad1b213..befa51a21dc2 100644 --- a/source/common/router/scoped_rds.h +++ b/source/common/router/scoped_rds.h @@ -4,7 +4,6 @@ #include "envoy/common/callback.h" #include "envoy/config/core/v3/config_source.pb.h" -#include "envoy/config/discovery_service_base.h" #include "envoy/config/route/v3/scoped_route.pb.h" #include "envoy/config/subscription.h" #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.pb.h" @@ -13,6 +12,7 @@ #include "envoy/stats/scope.h" #include "common/config/config_provider_impl.h" +#include "common/config/subscription_base.h" #include "common/init/manager_impl.h" #include "common/router/rds_impl.h" #include "common/router/scoped_config_impl.h" diff --git a/source/common/router/vhds.cc b/source/common/router/vhds.cc index a59f0dcccb51..75f8a9570887 100644 --- a/source/common/router/vhds.cc +++ b/source/common/router/vhds.cc @@ -25,7 +25,8 @@ VhdsSubscription::VhdsSubscription(RouteConfigUpdatePtr& config_update_info, const std::string& stat_prefix, std::unordered_set& route_config_providers, envoy::config::core::v3::ApiVersion resource_api_version) - : config_update_info_(config_update_info), + : Envoy::Config::SubscriptionBase(resource_api_version), + config_update_info_(config_update_info), scope_(factory_context.scope().createScope(stat_prefix + "vhds." + config_update_info_->routeConfigName() + ".")), stats_({ALL_VHDS_STATS(POOL_COUNTER(*scope_))}), @@ -40,7 +41,7 @@ VhdsSubscription::VhdsSubscription(RouteConfigUpdatePtr& config_update_info, if (config_source != envoy::config::core::v3::ApiConfigSource::DELTA_GRPC) { throw EnvoyException("vhds: only 'DELTA_GRPC' is supported as an api_type."); } - const auto resource_name = getResourceName(resource_api_version); + const auto resource_name = getResourceName(); subscription_ = factory_context.clusterManager().subscriptionFactory().subscriptionFromConfigSource( config_update_info_->routeConfiguration().vhds().config_source(), diff --git a/source/common/router/vhds.h b/source/common/router/vhds.h index fad39432700a..224e18e1a74d 100644 --- a/source/common/router/vhds.h +++ b/source/common/router/vhds.h @@ -7,7 +7,6 @@ #include #include "envoy/config/core/v3/config_source.pb.h" -#include "envoy/config/discovery_service_base.h" #include "envoy/config/route/v3/route_components.pb.h" #include "envoy/config/subscription.h" #include "envoy/http/codes.h" @@ -21,6 +20,7 @@ #include "envoy/thread_local/thread_local.h" #include "common/common/logger.h" +#include "common/config/subscription_base.h" #include "common/init/target_impl.h" #include "common/protobuf/utility.h" diff --git a/source/common/runtime/BUILD b/source/common/runtime/BUILD index 2d37e10aa0cf..fab542c3dbfa 100644 --- a/source/common/runtime/BUILD +++ b/source/common/runtime/BUILD @@ -34,7 +34,6 @@ envoy_cc_library( external_deps = ["ssl"], deps = [ ":runtime_features_lib", - "//include/envoy/config:discovery_service_base_interface", "//include/envoy/config:subscription_interface", "//include/envoy/event:dispatcher_interface", "//include/envoy/init:manager_interface", @@ -48,6 +47,7 @@ envoy_cc_library( "//source/common/common:thread_lib", "//source/common/common:utility_lib", "//source/common/config:api_version_lib", + "//source/common/config:subscription_base_interface", "//source/common/filesystem:directory_lib", "//source/common/grpc:common_lib", "//source/common/init:target_lib", diff --git a/source/common/runtime/runtime_impl.cc b/source/common/runtime/runtime_impl.cc index 0589defa6e90..dd9c9182a44d 100644 --- a/source/common/runtime/runtime_impl.cc +++ b/source/common/runtime/runtime_impl.cc @@ -542,7 +542,9 @@ void LoaderImpl::initialize(Upstream::ClusterManager& cm) { cm_ = &cm; } RtdsSubscription::RtdsSubscription( LoaderImpl& parent, const envoy::config::bootstrap::v3::RuntimeLayer::RtdsLayer& rtds_layer, Stats::Store& store, ProtobufMessage::ValidationVisitor& validation_visitor) - : parent_(parent), config_source_(rtds_layer.rtds_config()), store_(store), + : Envoy::Config::SubscriptionBase( + rtds_layer.rtds_config().resource_api_version()), + parent_(parent), config_source_(rtds_layer.rtds_config()), store_(store), resource_name_(rtds_layer.name()), init_target_("RTDS " + resource_name_, [this]() { start(); }), validation_visitor_(validation_visitor) {} @@ -583,7 +585,7 @@ void RtdsSubscription::start() { // We have to delay the subscription creation until init-time, since the // cluster manager resources are not available in the constructor when // instantiated in the server instance. - const auto resource_name = getResourceName(config_source_.resource_api_version()); + const auto resource_name = getResourceName(); subscription_ = parent_.cm_->subscriptionFactory().subscriptionFromConfigSource( config_source_, Grpc::Common::typeUrl(resource_name), store_, *this); subscription_->start({resource_name_}); diff --git a/source/common/runtime/runtime_impl.h b/source/common/runtime/runtime_impl.h index cc10dd5aa759..7e3443b21daf 100644 --- a/source/common/runtime/runtime_impl.h +++ b/source/common/runtime/runtime_impl.h @@ -9,7 +9,6 @@ #include "envoy/common/exception.h" #include "envoy/config/bootstrap/v3/bootstrap.pb.h" #include "envoy/config/core/v3/config_source.pb.h" -#include "envoy/config/discovery_service_base.h" #include "envoy/config/subscription.h" #include "envoy/init/manager.h" #include "envoy/runtime/runtime.h" @@ -24,6 +23,7 @@ #include "common/common/assert.h" #include "common/common/logger.h" #include "common/common/thread.h" +#include "common/config/subscription_base.h" #include "common/init/target_impl.h" #include "common/singleton/threadsafe_singleton.h" diff --git a/source/common/secret/BUILD b/source/common/secret/BUILD index df0e31f0cb5c..719c3e884af9 100644 --- a/source/common/secret/BUILD +++ b/source/common/secret/BUILD @@ -44,7 +44,6 @@ envoy_cc_library( srcs = ["sds_api.cc"], hdrs = ["sds_api.h"], deps = [ - "//include/envoy/config:discovery_service_base_interface", "//include/envoy/config:subscription_factory_interface", "//include/envoy/config:subscription_interface", "//include/envoy/event:dispatcher_interface", @@ -57,7 +56,7 @@ envoy_cc_library( "//source/common/common:callback_impl_lib", "//source/common/common:cleanup_lib", "//source/common/config:api_version_lib", - "//source/common/config:resources_lib", + "//source/common/config:subscription_base_interface", "//source/common/config:utility_lib", "//source/common/init:target_lib", "//source/common/protobuf:utility_lib", diff --git a/source/common/secret/sds_api.cc b/source/common/secret/sds_api.cc index 37697cb28417..deab859adafd 100644 --- a/source/common/secret/sds_api.cc +++ b/source/common/secret/sds_api.cc @@ -10,7 +10,6 @@ #include "common/common/assert.h" #include "common/config/api_version.h" -#include "common/config/resources.h" #include "common/protobuf/utility.h" namespace Envoy { @@ -21,7 +20,9 @@ SdsApi::SdsApi(envoy::config::core::v3::ConfigSource sds_config, absl::string_vi ProtobufMessage::ValidationVisitor& validation_visitor, Stats::Store& stats, Init::Manager& init_manager, std::function destructor_cb, Event::Dispatcher& dispatcher, Api::Api& api) - : init_target_(fmt::format("SdsApi {}", sds_config_name), [this] { initialize(); }), + : Envoy::Config::SubscriptionBase( + sds_config.resource_api_version()), + init_target_(fmt::format("SdsApi {}", sds_config_name), [this] { initialize(); }), stats_(stats), sds_config_(std::move(sds_config)), sds_config_name_(sds_config_name), secret_hash_(0), clean_up_(std::move(destructor_cb)), validation_visitor_(validation_visitor), subscription_factory_(subscription_factory), @@ -110,7 +111,7 @@ void SdsApi::validateUpdateSize(int num_resources) { } void SdsApi::initialize() { - const auto resource_name = getResourceName(sds_config_.resource_api_version()); + const auto resource_name = getResourceName(); subscription_ = subscription_factory_.subscriptionFromConfigSource( sds_config_, Grpc::Common::typeUrl(resource_name), stats_, *this); subscription_->start({sds_config_name_}); diff --git a/source/common/secret/sds_api.h b/source/common/secret/sds_api.h index d8433f21f250..0ca7c93f24aa 100644 --- a/source/common/secret/sds_api.h +++ b/source/common/secret/sds_api.h @@ -4,7 +4,6 @@ #include "envoy/api/api.h" #include "envoy/config/core/v3/config_source.pb.h" -#include "envoy/config/discovery_service_base.h" #include "envoy/config/subscription.h" #include "envoy/config/subscription_factory.h" #include "envoy/event/dispatcher.h" @@ -21,6 +20,7 @@ #include "common/common/callback_impl.h" #include "common/common/cleanup.h" +#include "common/config/subscription_base.h" #include "common/config/utility.h" #include "common/init/target_impl.h" #include "common/ssl/certificate_validation_context_config_impl.h" diff --git a/source/common/upstream/BUILD b/source/common/upstream/BUILD index 5687eac98508..608c24bbfb3f 100644 --- a/source/common/upstream/BUILD +++ b/source/common/upstream/BUILD @@ -13,14 +13,13 @@ envoy_cc_library( srcs = ["cds_api_impl.cc"], hdrs = ["cds_api_impl.h"], deps = [ - "//include/envoy/config:discovery_service_base_interface", "//include/envoy/config:subscription_interface", "//include/envoy/event:dispatcher_interface", "//include/envoy/local_info:local_info_interface", "//source/common/common:cleanup_lib", "//source/common/common:minimal_logger_lib", "//source/common/config:api_version_lib", - "//source/common/config:resources_lib", + "//source/common/config:subscription_base_interface", "//source/common/config:utility_lib", "//source/common/protobuf:utility_lib", "@envoy_api//envoy/api/v2:pkg_cc_proto", @@ -357,7 +356,6 @@ envoy_cc_library( deps = [ ":cluster_factory_lib", ":upstream_includes", - "//include/envoy/config:discovery_service_base_interface", "//include/envoy/config:grpc_mux_interface", "//include/envoy/config:subscription_factory_interface", "//include/envoy/config:subscription_interface", @@ -367,6 +365,7 @@ envoy_cc_library( "//include/envoy/upstream:locality_lib", "//source/common/config:api_version_lib", "//source/common/config:metadata_lib", + "//source/common/config:subscription_base_interface", "//source/common/config:subscription_factory_lib", "//source/common/config:utility_lib", "//source/common/config:version_converter_lib", diff --git a/source/common/upstream/cds_api_impl.cc b/source/common/upstream/cds_api_impl.cc index d7cf1534f6b5..2e83937b9877 100644 --- a/source/common/upstream/cds_api_impl.cc +++ b/source/common/upstream/cds_api_impl.cc @@ -30,9 +30,11 @@ CdsApiPtr CdsApiImpl::create(const envoy::config::core::v3::ConfigSource& cds_co CdsApiImpl::CdsApiImpl(const envoy::config::core::v3::ConfigSource& cds_config, ClusterManager& cm, Stats::Scope& scope, ProtobufMessage::ValidationVisitor& validation_visitor) - : cm_(cm), scope_(scope.createScope("cluster_manager.cds.")), + : Envoy::Config::SubscriptionBase( + cds_config.resource_api_version()), + cm_(cm), scope_(scope.createScope("cluster_manager.cds.")), validation_visitor_(validation_visitor) { - const auto resource_name = getResourceName(cds_config.resource_api_version()); + const auto resource_name = getResourceName(); subscription_ = cm_.subscriptionFactory().subscriptionFromConfigSource( cds_config, Grpc::Common::typeUrl(resource_name), *scope_, *this); } @@ -129,4 +131,4 @@ void CdsApiImpl::runInitializeCallbackIfAny() { } } // namespace Upstream -} // namespace Envoy +} // namespace Envoy \ No newline at end of file diff --git a/source/common/upstream/cds_api_impl.h b/source/common/upstream/cds_api_impl.h index 5eca7076befe..f2f66340e9b0 100644 --- a/source/common/upstream/cds_api_impl.h +++ b/source/common/upstream/cds_api_impl.h @@ -5,7 +5,6 @@ #include "envoy/api/api.h" #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/config/core/v3/config_source.pb.h" -#include "envoy/config/discovery_service_base.h" #include "envoy/config/subscription.h" #include "envoy/event/dispatcher.h" #include "envoy/local_info/local_info.h" @@ -14,6 +13,7 @@ #include "envoy/upstream/cluster_manager.h" #include "common/common/logger.h" +#include "common/config/subscription_base.h" namespace Envoy { namespace Upstream { diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index aa5f724446f6..a8da8b3c1d1e 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -1369,4 +1369,4 @@ ProdClusterManagerFactory::createCds(const envoy::config::core::v3::ConfigSource } } // namespace Upstream -} // namespace Envoy +} // namespace Envoy \ No newline at end of file diff --git a/source/common/upstream/eds.cc b/source/common/upstream/eds.cc index 844a3f26a0e4..03a12914cfa8 100644 --- a/source/common/upstream/eds.cc +++ b/source/common/upstream/eds.cc @@ -22,6 +22,8 @@ EdsClusterImpl::EdsClusterImpl( Stats::ScopePtr&& stats_scope, bool added_via_api) : BaseDynamicClusterImpl(cluster, runtime, factory_context, std::move(stats_scope), added_via_api), + Envoy::Config::SubscriptionBase( + cluster.eds_cluster_config().eds_config().resource_api_version()), local_info_(factory_context.localInfo()), cluster_name_(cluster.eds_cluster_config().service_name().empty() ? cluster.name() @@ -36,8 +38,7 @@ EdsClusterImpl::EdsClusterImpl( } else { initialize_phase_ = InitializePhase::Secondary; } - const auto resource_name = - getResourceName(cluster.eds_cluster_config().eds_config().resource_api_version()); + const auto resource_name = getResourceName(); subscription_ = factory_context.clusterManager().subscriptionFactory().subscriptionFromConfigSource( eds_config, Grpc::Common::typeUrl(resource_name), info_->statsScope(), *this); diff --git a/source/common/upstream/eds.h b/source/common/upstream/eds.h index ebe8dc375523..fa3b09eb8cca 100644 --- a/source/common/upstream/eds.h +++ b/source/common/upstream/eds.h @@ -3,7 +3,6 @@ #include "envoy/config/cluster/v3/cluster.pb.h" #include "envoy/config/core/v3/base.pb.h" #include "envoy/config/core/v3/config_source.pb.h" -#include "envoy/config/discovery_service_base.h" #include "envoy/config/endpoint/v3/endpoint.pb.h" #include "envoy/config/subscription.h" #include "envoy/config/subscription_factory.h" @@ -13,6 +12,7 @@ #include "envoy/stats/scope.h" #include "envoy/upstream/locality.h" +#include "common/config/subscription_base.h" #include "common/upstream/cluster_factory_impl.h" #include "common/upstream/upstream_impl.h" diff --git a/source/server/BUILD b/source/server/BUILD index e7fa6df94593..e7b2f397c33e 100644 --- a/source/server/BUILD +++ b/source/server/BUILD @@ -255,14 +255,13 @@ envoy_cc_library( srcs = ["lds_api.cc"], hdrs = ["lds_api.h"], deps = [ - "//include/envoy/config:discovery_service_base_interface", "//include/envoy/config:subscription_factory_interface", "//include/envoy/config:subscription_interface", "//include/envoy/init:manager_interface", "//include/envoy/server:listener_manager_interface", "//source/common/common:cleanup_lib", "//source/common/config:api_version_lib", - "//source/common/config:resources_lib", + "//source/common/config:subscription_base_interface", "//source/common/config:utility_lib", "//source/common/init:target_lib", "//source/common/protobuf:utility_lib", diff --git a/source/server/lds_api.cc b/source/server/lds_api.cc index b799140835be..5f4cecafc6ce 100644 --- a/source/server/lds_api.cc +++ b/source/server/lds_api.cc @@ -26,10 +26,12 @@ LdsApiImpl::LdsApiImpl(const envoy::config::core::v3::ConfigSource& lds_config, Upstream::ClusterManager& cm, Init::Manager& init_manager, Stats::Scope& scope, ListenerManager& lm, ProtobufMessage::ValidationVisitor& validation_visitor) - : listener_manager_(lm), scope_(scope.createScope("listener_manager.lds.")), cm_(cm), + : Envoy::Config::SubscriptionBase( + lds_config.resource_api_version()), + listener_manager_(lm), scope_(scope.createScope("listener_manager.lds.")), cm_(cm), init_target_("LDS", [this]() { subscription_->start({}); }), validation_visitor_(validation_visitor) { - const auto resource_name = getResourceName(lds_config.resource_api_version()); + const auto resource_name = getResourceName(); subscription_ = cm.subscriptionFactory().subscriptionFromConfigSource( lds_config, Grpc::Common::typeUrl(resource_name), *scope_, *this); init_manager.add(init_target_); @@ -135,4 +137,4 @@ void LdsApiImpl::onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason r } } // namespace Server -} // namespace Envoy +} // namespace Envoy \ No newline at end of file diff --git a/source/server/lds_api.h b/source/server/lds_api.h index 5a1f64d916fd..00a415563668 100644 --- a/source/server/lds_api.h +++ b/source/server/lds_api.h @@ -3,7 +3,6 @@ #include #include "envoy/config/core/v3/config_source.pb.h" -#include "envoy/config/discovery_service_base.h" #include "envoy/config/listener/v3/listener.pb.h" #include "envoy/config/subscription.h" #include "envoy/config/subscription_factory.h" @@ -13,6 +12,7 @@ #include "envoy/stats/scope.h" #include "common/common/logger.h" +#include "common/config/subscription_base.h" #include "common/init/target_impl.h" namespace Envoy { diff --git a/source/server/server.cc b/source/server/server.cc index 528c18472987..6d7fdde43c5f 100644 --- a/source/server/server.cc +++ b/source/server/server.cc @@ -679,4 +679,4 @@ ProtobufTypes::MessagePtr InstanceImpl::dumpBootstrapConfig() { } } // namespace Server -} // namespace Envoy +} // namespace Envoy \ No newline at end of file