Skip to content

Commit

Permalink
format: use type alias (#12146)
Browse files Browse the repository at this point in the history
Commit Message: format: use type alias
Additional Description: N/A
Risk Level: Low
Testing: N/A
Docs Changes: N/A
Release Notes: N/A
Part of #11634

Signed-off-by: tomocy <[email protected]>
  • Loading branch information
tomocy authored Jul 17, 2020
1 parent 57b4a1e commit bc02b77
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 28 deletions.
4 changes: 4 additions & 0 deletions include/envoy/router/route_config_provider_manager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <memory>
#include <string>

#include "envoy/config/route/v3/route.pb.h"
Expand Down Expand Up @@ -55,5 +56,8 @@ class RouteConfigProviderManager {
ProtobufMessage::ValidationVisitor& validator) PURE;
};

using RouteConfigProviderManagerPtr = std::unique_ptr<RouteConfigProviderManager>;
using RouteConfigProviderManagerSharedPtr = std::shared_ptr<RouteConfigProviderManager>;

} // namespace Router
} // namespace Envoy
2 changes: 1 addition & 1 deletion source/common/router/rds_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ Router::RouteConfigProviderSharedPtr RouteConfigProviderManagerImpl::createRdsRo
RdsRouteConfigSubscriptionSharedPtr subscription(new RdsRouteConfigSubscription(
rds, manager_identifier, factory_context, stat_prefix, *this));
init_manager.add(subscription->parent_init_target_);
std::shared_ptr<RdsRouteConfigProviderImpl> new_provider{
RdsRouteConfigProviderImplSharedPtr new_provider{
new RdsRouteConfigProviderImpl(std::move(subscription), factory_context)};
dynamic_route_config_providers_.insert(
{manager_identifier, std::weak_ptr<RdsRouteConfigProviderImpl>(new_provider)});
Expand Down
7 changes: 6 additions & 1 deletion source/common/router/rds_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <cstdint>
#include <functional>
#include <memory>
#include <queue>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -149,7 +150,7 @@ class RdsRouteConfigSubscription

bool validateUpdateSize(int num_resources);

std::unique_ptr<Envoy::Config::Subscription> subscription_;
Envoy::Config::SubscriptionPtr subscription_;
const std::string route_config_name_;
Server::Configuration::ServerFactoryContext& factory_context_;

Expand Down Expand Up @@ -227,6 +228,8 @@ class RdsRouteConfigProviderImpl : public RouteConfigProvider,
friend class RouteConfigProviderManagerImpl;
};

using RdsRouteConfigProviderImplSharedPtr = std::shared_ptr<RdsRouteConfigProviderImpl>;

class RouteConfigProviderManagerImpl : public RouteConfigProviderManager,
public Singleton::Instance {
public:
Expand Down Expand Up @@ -258,5 +261,7 @@ class RouteConfigProviderManagerImpl : public RouteConfigProviderManager,
friend class StaticRouteConfigProviderImpl;
};

using RouteConfigProviderManagerImplPtr = std::unique_ptr<RouteConfigProviderManagerImpl>;

} // namespace Router
} // namespace Envoy
6 changes: 3 additions & 3 deletions source/common/router/scoped_rds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ bool ScopedRdsConfigSubscription::addOrUpdateScopes(
return any_applied;
}

std::list<std::unique_ptr<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper>>
std::list<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelperPtr>
ScopedRdsConfigSubscription::removeScopes(
const Protobuf::RepeatedPtrField<std::string>& scope_names, const std::string& version_info) {
std::list<std::unique_ptr<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper>>
std::list<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelperPtr>
to_be_removed_rds_providers;
for (const auto& scope_name : scope_names) {
auto iter = scoped_route_map_.find(scope_name);
Expand Down Expand Up @@ -266,7 +266,7 @@ void ScopedRdsConfigSubscription::onConfigUpdate(
std::vector<std::string> exception_msgs;
// Do not delete RDS config providers just yet, in case the to be deleted RDS subscriptions could
// be reused by some to be added scopes.
std::list<std::unique_ptr<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelper>>
std::list<ScopedRdsConfigSubscription::RdsRouteConfigProviderHelperPtr>
to_be_removed_rds_providers = removeScopes(removed_resources, version_info);
bool any_applied =
addOrUpdateScopes(added_resources,
Expand Down
16 changes: 11 additions & 5 deletions source/common/router/scoped_rds.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <memory>
#include <string>

#include "envoy/common/callback.h"
Expand Down Expand Up @@ -123,12 +124,14 @@ class ScopedRdsConfigSubscription

ScopedRdsConfigSubscription& parent_;
std::string scope_name_;
std::shared_ptr<RdsRouteConfigProviderImpl> route_provider_;
RdsRouteConfigProviderImplSharedPtr route_provider_;
// This handle_ is owned by the route config provider's RDS subscription, when the helper
// destructs, the handle is deleted as well.
Common::CallbackHandle* rds_update_callback_handle_;
};

using RdsRouteConfigProviderHelperPtr = std::unique_ptr<RdsRouteConfigProviderHelper>;

// Adds or updates scopes, create a new RDS provider for each resource, if an exception is thrown
// during updating, the exception message is collected via the exception messages vector.
// Returns true if any scope updated, false otherwise.
Expand All @@ -138,7 +141,7 @@ class ScopedRdsConfigSubscription
// Removes given scopes from the managed set of scopes.
// Returns a list of to be removed helpers which is temporally held in the onConfigUpdate method,
// to make sure new scopes sharing the same RDS source configs could reuse the subscriptions.
std::list<std::unique_ptr<RdsRouteConfigProviderHelper>>
std::list<RdsRouteConfigProviderHelperPtr>
removeScopes(const Protobuf::RepeatedPtrField<std::string>& scope_names,
const std::string& version_info);

Expand Down Expand Up @@ -169,14 +172,13 @@ class ScopedRdsConfigSubscription
ScopedRouteMap scoped_route_map_;

// RdsRouteConfigProvider by scope name.
absl::flat_hash_map<std::string, std::unique_ptr<RdsRouteConfigProviderHelper>>
route_provider_by_scope_;
absl::flat_hash_map<std::string, RdsRouteConfigProviderHelperPtr> route_provider_by_scope_;
// A map of (hash, scope-name), used to detect the key conflict between scopes.
absl::flat_hash_map<uint64_t, std::string> scope_name_by_hash_;
// For creating RDS subscriptions.
Server::Configuration::ServerFactoryContext& factory_context_;
const std::string name_;
std::unique_ptr<Envoy::Config::Subscription> subscription_;
Envoy::Config::SubscriptionPtr subscription_;
const envoy::extensions::filters::network::http_connection_manager::v3::ScopedRoutes::
ScopeKeyBuilder scope_key_builder_;
Stats::ScopePtr scope_;
Expand Down Expand Up @@ -240,6 +242,10 @@ class ScopedRoutesConfigProviderManager : public Envoy::Config::ConfigProviderMa
RouteConfigProviderManager& route_config_provider_manager_;
};

using ScopedRoutesConfigProviderManagerPtr = std::unique_ptr<ScopedRoutesConfigProviderManager>;
using ScopedRoutesConfigProviderManagerSharedPtr =
std::shared_ptr<ScopedRoutesConfigProviderManager>;

// The optional argument passed to the ConfigProviderManager::create*() functions.
class ScopedRoutesConfigProviderManagerOptArg
: public Envoy::Config::ConfigProviderManager::OptionalArg {
Expand Down
2 changes: 1 addition & 1 deletion source/common/router/vhds.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class VhdsSubscription : Envoy::Config::SubscriptionBase<envoy::config::route::v
RouteConfigUpdatePtr& config_update_info_;
Stats::ScopePtr scope_;
VhdsStats stats_;
std::unique_ptr<Envoy::Config::Subscription> subscription_;
Envoy::Config::SubscriptionPtr subscription_;
Init::TargetImpl init_target_;
std::unordered_set<RouteConfigProvider*>& route_config_providers_;
};
Expand Down
2 changes: 1 addition & 1 deletion source/common/secret/sds_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SdsApi : public Envoy::Config::SubscriptionBase<
Stats::Store& stats_;

const envoy::config::core::v3::ConfigSource sds_config_;
std::unique_ptr<Config::Subscription> subscription_;
Config::SubscriptionPtr subscription_;
const std::string sds_config_name_;

uint64_t secret_hash_;
Expand Down
2 changes: 1 addition & 1 deletion source/common/upstream/cds_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CdsApiImpl : public CdsApi,
void runInitializeCallbackIfAny();

ClusterManager& cm_;
std::unique_ptr<Config::Subscription> subscription_;
Config::SubscriptionPtr subscription_;
std::string system_version_info_;
std::function<void()> initialize_callback_;
Stats::ScopePtr scope_;
Expand Down
6 changes: 5 additions & 1 deletion source/common/upstream/eds.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <memory>

#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"
Expand Down Expand Up @@ -74,7 +76,7 @@ class EdsClusterImpl
const envoy::config::endpoint::v3::ClusterLoadAssignment& cluster_load_assignment_;
};

std::unique_ptr<Config::Subscription> subscription_;
Config::SubscriptionPtr subscription_;
const LocalInfo::LocalInfo& local_info_;
const std::string cluster_name_;
std::vector<LocalityWeightsMap> locality_weights_map_;
Expand All @@ -83,6 +85,8 @@ class EdsClusterImpl
InitializePhase initialize_phase_;
};

using EdsClusterImplSharedPtr = std::shared_ptr<EdsClusterImpl>;

class EdsClusterFactory : public ClusterFactoryImplBase {
public:
EdsClusterFactory() : ClusterFactoryImplBase(Extensions::Clusters::ClusterTypes::get().Eds) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ Utility::Singletons Utility::createSingletons(Server::Configuration::FactoryCont
context.threadLocal());
});

std::shared_ptr<Router::RouteConfigProviderManager> route_config_provider_manager =
Router::RouteConfigProviderManagerSharedPtr route_config_provider_manager =
context.singletonManager().getTyped<Router::RouteConfigProviderManager>(
SINGLETON_MANAGER_REGISTERED_NAME(route_config_provider_manager), [&context] {
return std::make_shared<Router::RouteConfigProviderManagerImpl>(context.admin());
});

std::shared_ptr<Router::ScopedRoutesConfigProviderManager> scoped_routes_config_provider_manager =
Router::ScopedRoutesConfigProviderManagerSharedPtr scoped_routes_config_provider_manager =
context.singletonManager().getTyped<Router::ScopedRoutesConfigProviderManager>(
SINGLETON_MANAGER_REGISTERED_NAME(scoped_routes_config_provider_manager),
[&context, route_config_provider_manager] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ class Utility {
public:
struct Singletons {
std::shared_ptr<Http::TlsCachingDateProviderImpl> date_provider_;
std::shared_ptr<Router::RouteConfigProviderManager> route_config_provider_manager_;
std::shared_ptr<Router::ScopedRoutesConfigProviderManager>
scoped_routes_config_provider_manager_;
Router::RouteConfigProviderManagerSharedPtr route_config_provider_manager_;
Router::ScopedRoutesConfigProviderManagerSharedPtr scoped_routes_config_provider_manager_;
Tracing::HttpTracerManagerSharedPtr http_tracer_manager_;
};

Expand Down
2 changes: 1 addition & 1 deletion source/server/lds_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class LdsApiImpl : public LdsApi,
void onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason reason,
const EnvoyException* e) override;

std::unique_ptr<Config::Subscription> subscription_;
Config::SubscriptionPtr subscription_;
std::string system_version_info_;
ListenerManager& listener_manager_;
Stats::ScopePtr scope_;
Expand Down
2 changes: 1 addition & 1 deletion test/common/config/subscription_factory_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SubscriptionFactoryTest : public testing::Test {
subscription_factory_(local_info_, dispatcher_, cm_, random_, validation_visitor_, *api_,
runtime_) {}

std::unique_ptr<Subscription>
SubscriptionPtr
subscriptionFromConfigSource(const envoy::config::core::v3::ConfigSource& config) {
return subscription_factory_.subscriptionFromConfigSource(
config, Config::TypeUrl::get().ClusterLoadAssignment, stats_store_, callbacks_,
Expand Down
6 changes: 3 additions & 3 deletions test/common/router/rds_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ stat_prefix: foo
}

NiceMock<Server::MockInstance> server_;
std::unique_ptr<RouteConfigProviderManagerImpl> route_config_provider_manager_;
RouteConfigProviderManagerImplPtr route_config_provider_manager_;
RouteConfigProviderSharedPtr rds_;
};

Expand Down Expand Up @@ -290,7 +290,7 @@ class RdsRouteConfigSubscriptionTest : public RdsTestBase {
server_factory_context_.thread_local_.shutdownThread();
}

std::unique_ptr<RouteConfigProviderManagerImpl> route_config_provider_manager_;
RouteConfigProviderManagerImplPtr route_config_provider_manager_;
};

// Verifies that maybeCreateInitManager() creates a noop init manager if the main init manager is in
Expand Down Expand Up @@ -353,7 +353,7 @@ class RouteConfigProviderManagerImplTest : public RdsTestBase {
}

envoy::extensions::filters::network::http_connection_manager::v3::Rds rds_;
std::unique_ptr<RouteConfigProviderManagerImpl> route_config_provider_manager_;
RouteConfigProviderManagerImplPtr route_config_provider_manager_;
RouteConfigProviderSharedPtr provider_;
};

Expand Down
4 changes: 2 additions & 2 deletions test/common/router/scoped_rds_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class ScopedRoutesTestBase : public testing::Test {
NiceMock<ProtobufMessage::MockValidationContext> validation_context_;
// server_factory_context_ is used by rds
NiceMock<Server::Configuration::MockServerFactoryContext> server_factory_context_;
std::unique_ptr<RouteConfigProviderManager> route_config_provider_manager_;
std::unique_ptr<ScopedRoutesConfigProviderManager> config_provider_manager_;
RouteConfigProviderManagerPtr route_config_provider_manager_;
ScopedRoutesConfigProviderManagerPtr config_provider_manager_;

Event::SimulatedTimeSystem time_system_;
};
Expand Down
2 changes: 1 addition & 1 deletion test/common/upstream/eds_speed_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class EdsSpeedTest {
envoy::config::cluster::v3::Cluster eds_cluster_;
NiceMock<MockClusterManager> cm_;
NiceMock<Event::MockDispatcher> dispatcher_;
std::shared_ptr<EdsClusterImpl> cluster_;
EdsClusterImplSharedPtr cluster_;
Config::SubscriptionCallbacks* eds_callbacks_{};
Config::OpaqueResourceDecoderImpl<envoy::config::endpoint::v3::ClusterLoadAssignment>
resource_decoder_{validation_visitor_, "cluster_name"};
Expand Down
2 changes: 1 addition & 1 deletion test/common/upstream/eds_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class EdsTest : public testing::Test {
envoy::config::cluster::v3::Cluster eds_cluster_;
NiceMock<MockClusterManager> cm_;
NiceMock<Event::MockDispatcher> dispatcher_;
std::shared_ptr<EdsClusterImpl> cluster_;
EdsClusterImplSharedPtr cluster_;
Config::SubscriptionCallbacks* eds_callbacks_{};
NiceMock<Random::MockRandomGenerator> random_;
NiceMock<Runtime::MockLoader> runtime_;
Expand Down

0 comments on commit bc02b77

Please sign in to comment.