Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subscription: cleaning up unused argument #18212

Merged
merged 2 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions source/common/config/subscription_factory_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ SubscriptionPtr SubscriptionFactoryImpl::subscriptionFromConfigSource(
Utility::checkApiConfigSourceSubscriptionBackingCluster(cm_.primaryClusters(),
api_config_source);
Utility::checkTransportVersion(api_config_source);
const auto transport_api_version = envoy::config::core::v3::ApiVersion::V3;
switch (api_config_source.api_type()) {
case envoy::config::core::v3::ApiConfigSource::DEPRECATED_AND_UNAVAILABLE_DO_NOT_USE:
throw EnvoyException(
Expand All @@ -53,18 +52,18 @@ SubscriptionPtr SubscriptionFactoryImpl::subscriptionFromConfigSource(
return std::make_unique<HttpSubscriptionImpl>(
local_info_, cm_, api_config_source.cluster_names()[0], dispatcher_,
api_.randomGenerator(), Utility::apiConfigSourceRefreshDelay(api_config_source),
Utility::apiConfigSourceRequestTimeout(api_config_source),
restMethod(type_url, transport_api_version), type_url, callbacks, resource_decoder, stats,
Utility::configSourceInitialFetchTimeout(config), validation_visitor_);
Utility::apiConfigSourceRequestTimeout(api_config_source), restMethod(type_url), type_url,
callbacks, resource_decoder, stats, Utility::configSourceInitialFetchTimeout(config),
validation_visitor_);
case envoy::config::core::v3::ApiConfigSource::GRPC:
return std::make_unique<GrpcSubscriptionImpl>(
std::make_shared<Config::GrpcMuxImpl>(
local_info_,
Utility::factoryForGrpcApiConfigSource(cm_.grpcAsyncClientManager(),
api_config_source, scope, true)
->createUncachedRawAsyncClient(),
dispatcher_, sotwGrpcMethod(type_url, transport_api_version), api_.randomGenerator(),
scope, Utility::parseRateLimitSettings(api_config_source),
dispatcher_, sotwGrpcMethod(type_url), api_.randomGenerator(), scope,
Utility::parseRateLimitSettings(api_config_source),
api_config_source.set_node_on_first_message_only()),
callbacks, resource_decoder, stats, type_url, dispatcher_,
Utility::configSourceInitialFetchTimeout(config),
Expand All @@ -75,8 +74,8 @@ SubscriptionPtr SubscriptionFactoryImpl::subscriptionFromConfigSource(
Config::Utility::factoryForGrpcApiConfigSource(cm_.grpcAsyncClientManager(),
api_config_source, scope, true)
->createUncachedRawAsyncClient(),
dispatcher_, deltaGrpcMethod(type_url, transport_api_version), api_.randomGenerator(),
scope, Utility::parseRateLimitSettings(api_config_source), local_info_),
dispatcher_, deltaGrpcMethod(type_url), api_.randomGenerator(), scope,
Utility::parseRateLimitSettings(api_config_source), local_info_),
callbacks, resource_decoder, stats, type_url, dispatcher_,
Utility::configSourceInitialFetchTimeout(config), /*is_aggregated*/ false, options);
}
Expand Down Expand Up @@ -133,9 +132,8 @@ SubscriptionPtr SubscriptionFactoryImpl::collectionSubscriptionFromUrl(
Config::Utility::factoryForGrpcApiConfigSource(cm_.grpcAsyncClientManager(),
api_config_source, scope, true)
->createUncachedRawAsyncClient(),
dispatcher_, deltaGrpcMethod(type_url, envoy::config::core::v3::ApiVersion::V3),
api_.randomGenerator(), scope, Utility::parseRateLimitSettings(api_config_source),
local_info_),
dispatcher_, deltaGrpcMethod(type_url), api_.randomGenerator(), scope,
Utility::parseRateLimitSettings(api_config_source), local_info_),
callbacks, resource_decoder, stats, dispatcher_,
Utility::configSourceInitialFetchTimeout(config), false, options);
}
Expand Down
13 changes: 3 additions & 10 deletions source/common/config/type_to_endpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,19 @@ TypeUrlToV3ServiceMap& typeUrlToV3ServiceMap() {

} // namespace

// TODO(alyssawilk) clean up transport_api_version argument.
const Protobuf::MethodDescriptor&
deltaGrpcMethod(absl::string_view type_url,
envoy::config::core::v3::ApiVersion /*transport_api_version*/) {
const Protobuf::MethodDescriptor& deltaGrpcMethod(absl::string_view type_url) {
const auto it = typeUrlToV3ServiceMap().find(static_cast<TypeUrl>(type_url));
ASSERT(it != typeUrlToV3ServiceMap().cend());
return *Protobuf::DescriptorPool::generated_pool()->FindMethodByName(it->second.delta_grpc_);
}

const Protobuf::MethodDescriptor&
sotwGrpcMethod(absl::string_view type_url,
envoy::config::core::v3::ApiVersion /*transport_api_version*/) {
const Protobuf::MethodDescriptor& sotwGrpcMethod(absl::string_view type_url) {
const auto it = typeUrlToV3ServiceMap().find(static_cast<TypeUrl>(type_url));
ASSERT(it != typeUrlToV3ServiceMap().cend());
return *Protobuf::DescriptorPool::generated_pool()->FindMethodByName(it->second.sotw_grpc_);
}

const Protobuf::MethodDescriptor&
restMethod(absl::string_view type_url,
envoy::config::core::v3::ApiVersion /*transport_api_version*/) {
const Protobuf::MethodDescriptor& restMethod(absl::string_view type_url) {
const auto it = typeUrlToV3ServiceMap().find(static_cast<TypeUrl>(type_url));
ASSERT(it != typeUrlToV3ServiceMap().cend());
return *Protobuf::DescriptorPool::generated_pool()->FindMethodByName(it->second.rest_);
Expand Down
12 changes: 3 additions & 9 deletions source/common/config/type_to_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ namespace Envoy {
namespace Config {

// Translates an xDS resource type_url to the name of the delta gRPC service that carries it.
const Protobuf::MethodDescriptor&
deltaGrpcMethod(absl::string_view resource_type_url,
envoy::config::core::v3::ApiVersion transport_api_version);
const Protobuf::MethodDescriptor& deltaGrpcMethod(absl::string_view resource_type_url);
// Translates an xDS resource type_url to the name of the state-of-the-world gRPC service that
// carries it.
const Protobuf::MethodDescriptor&
sotwGrpcMethod(absl::string_view resource_type_url,
envoy::config::core::v3::ApiVersion transport_api_version);
const Protobuf::MethodDescriptor& sotwGrpcMethod(absl::string_view resource_type_url);
// Translates an xDS resource type_url to the name of the REST service that carries it.
const Protobuf::MethodDescriptor&
restMethod(absl::string_view resource_type_url,
envoy::config::core::v3::ApiVersion transport_api_version);
const Protobuf::MethodDescriptor& restMethod(absl::string_view resource_type_url);

} // namespace Config
} // namespace Envoy
36 changes: 14 additions & 22 deletions test/common/config/type_to_endpoint_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,26 @@ TEST(TypeToEndpoint, All) {
envoy::service::route::v3::RdsDummy _v3_rds_dummy;

// Delta gRPC endpoints.
EXPECT_EQ("envoy.service.route.v3.RouteDiscoveryService.DeltaRoutes",
deltaGrpcMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
envoy::config::core::v3::ApiVersion::AUTO)
.full_name());
EXPECT_EQ("envoy.service.route.v3.RouteDiscoveryService.DeltaRoutes",
deltaGrpcMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
envoy::config::core::v3::ApiVersion::V3)
.full_name());
EXPECT_EQ(
"envoy.service.route.v3.RouteDiscoveryService.DeltaRoutes",
deltaGrpcMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration").full_name());
EXPECT_EQ(
"envoy.service.route.v3.RouteDiscoveryService.DeltaRoutes",
deltaGrpcMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration").full_name());

// SotW gRPC endpoints.
EXPECT_EQ("envoy.service.route.v3.RouteDiscoveryService.StreamRoutes",
sotwGrpcMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
envoy::config::core::v3::ApiVersion::AUTO)
.full_name());
EXPECT_EQ("envoy.service.route.v3.RouteDiscoveryService.StreamRoutes",
sotwGrpcMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
envoy::config::core::v3::ApiVersion::V3)
.full_name());
EXPECT_EQ(
"envoy.service.route.v3.RouteDiscoveryService.StreamRoutes",
sotwGrpcMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration").full_name());
EXPECT_EQ(
"envoy.service.route.v3.RouteDiscoveryService.StreamRoutes",
sotwGrpcMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration").full_name());

// REST endpoints.
EXPECT_EQ("envoy.service.route.v3.RouteDiscoveryService.FetchRoutes",
restMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
envoy::config::core::v3::ApiVersion::AUTO)
.full_name());
restMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration").full_name());
EXPECT_EQ("envoy.service.route.v3.RouteDiscoveryService.FetchRoutes",
restMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
envoy::config::core::v3::ApiVersion::V3)
.full_name());
restMethod("type.googleapis.com/envoy.config.route.v3.RouteConfiguration").full_name());
}

} // namespace
Expand Down