From 78c9644bc7a3e3a6409fc4c49126bce325fb5bb3 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Fri, 17 Jan 2020 13:45:29 -0800 Subject: [PATCH 1/5] style: convention for optional reference wrapper type alias Signed-off-by: Jose Nino --- STYLE.md | 3 +++ include/envoy/api/api.h | 2 +- include/envoy/network/listen_socket.h | 1 + include/envoy/network/listener.h | 2 +- include/envoy/server/filter_config.h | 4 ++-- include/envoy/server/instance.h | 2 +- include/envoy/server/process_context.h | 4 +++- include/envoy/stats/scope.h | 12 +++++----- source/common/api/api_impl.cc | 2 +- source/common/api/api_impl.h | 6 ++--- .../addr_family_aware_socket_option_impl.cc | 5 ++--- source/common/network/socket_option_impl.h | 2 ++ source/common/stats/isolated_store_impl.h | 9 ++++---- source/common/stats/scope_prefixer.cc | 6 ++--- source/common/stats/scope_prefixer.h | 6 ++--- source/common/stats/stat_merger.cc | 2 +- source/common/stats/thread_local_store.cc | 6 ++--- source/common/stats/thread_local_store.h | 18 +++++++-------- .../common/upstream/cluster_manager_impl.cc | 2 +- source/common/upstream/conn_pool_map.h | 4 ++-- source/common/upstream/conn_pool_map_impl.h | 2 +- .../common/upstream/priority_conn_pool_map.h | 4 ++-- .../upstream/priority_conn_pool_map_impl.h | 2 +- source/server/config_validation/server.h | 2 +- source/server/filter_chain_manager_impl.cc | 2 +- source/server/filter_chain_manager_impl.h | 2 +- source/server/http/admin.h | 4 +--- source/server/listener_impl.cc | 2 +- source/server/listener_impl.h | 4 ++-- source/server/server.cc | 2 +- source/server/server.h | 2 +- test/common/stats/isolated_store_impl_test.cc | 6 ++--- test/common/stats/stat_merger_test.cc | 2 +- .../upstream/conn_pool_map_impl_test.cc | 8 +++---- .../network/zookeeper_proxy/filter_test.cc | 2 +- test/integration/fake_upstream.h | 2 +- test/integration/filters/eds_ready_filter.cc | 2 +- test/integration/integration.h | 2 +- test/integration/server.cc | 8 +++---- test/integration/server.h | 22 +++++++++---------- test/mocks/api/mocks.h | 2 +- test/mocks/network/mocks.h | 2 +- test/mocks/server/mocks.h | 4 ++-- test/mocks/stats/mocks.h | 6 ++--- 44 files changed, 100 insertions(+), 94 deletions(-) diff --git a/STYLE.md b/STYLE.md index f25aa1b7977c2..878750219bbcc 100644 --- a/STYLE.md +++ b/STYLE.md @@ -43,6 +43,9 @@ * `using BarSharedPtr = std::shared_ptr;` * `using BlahConstSharedPtr = std::shared_ptr;` * Regular pointers (e.g. `int* foo`) should not be type aliased. +* `absl::optional> is type aliased: + * `using FooOptRef = absl::optional>;` + * `using FooOptConstRef = absl::optional>;` * If move semantics are intended, prefer specifying function arguments with `&&`. E.g., `void onHeaders(Http::HeaderMapPtr&& headers, ...)`. The rationale for this is that it forces the caller to specify `std::move(...)` or pass a temporary and makes the intention at diff --git a/include/envoy/api/api.h b/include/envoy/api/api.h index 85b3ae8b81dd0..08827d8b3f842 100644 --- a/include/envoy/api/api.h +++ b/include/envoy/api/api.h @@ -57,7 +57,7 @@ class Api { /** * @return an optional reference to the ProcessContext */ - virtual OptProcessContextRef processContext() PURE; + virtual ProcessContextOptRef processContext() PURE; }; using ApiPtr = std::unique_ptr; diff --git a/include/envoy/network/listen_socket.h b/include/envoy/network/listen_socket.h index b31551094662d..aa5957eae499d 100644 --- a/include/envoy/network/listen_socket.h +++ b/include/envoy/network/listen_socket.h @@ -173,6 +173,7 @@ class Socket { using SocketPtr = std::unique_ptr; using SocketSharedPtr = std::shared_ptr; +using SocketOptRef = absl::optional>; /** * A socket passed to a connection. For server connections this represents the accepted socket, and diff --git a/include/envoy/network/listener.h b/include/envoy/network/listener.h index e633402e7fda7..4aed7d2b5f790 100644 --- a/include/envoy/network/listener.h +++ b/include/envoy/network/listener.h @@ -47,7 +47,7 @@ class ListenSocketFactory { /** * @return the socket shared by worker threads if any; otherwise return null. */ - virtual absl::optional> sharedSocket() const PURE; + virtual SocketOptRef sharedSocket() const PURE; }; using ListenSocketFactorySharedPtr = std::shared_ptr; diff --git a/include/envoy/server/filter_config.h b/include/envoy/server/filter_config.h index 7d078977010b6..49c95552f3bb5 100644 --- a/include/envoy/server/filter_config.h +++ b/include/envoy/server/filter_config.h @@ -189,10 +189,10 @@ class FactoryContext : public virtual CommonFactoryContext { virtual Grpc::Context& grpcContext() PURE; /** - * @return OptProcessContextRef an optional reference to the + * @return ProcessContextOptRef an optional reference to the * process context. Will be unset when running in validation mode. */ - virtual OptProcessContextRef processContext() PURE; + virtual ProcessContextOptRef processContext() PURE; /** * @return ProtobufMessage::ValidationVisitor& validation visitor for filter configuration diff --git a/include/envoy/server/instance.h b/include/envoy/server/instance.h index 59e3a9a8b93e1..18a976b88a4bc 100644 --- a/include/envoy/server/instance.h +++ b/include/envoy/server/instance.h @@ -196,7 +196,7 @@ class Instance { /** * @return the server-wide process context. */ - virtual OptProcessContextRef processContext() PURE; + virtual ProcessContextOptRef processContext() PURE; /** * @return ThreadLocal::Instance& the thread local storage engine for the server. This is used to diff --git a/include/envoy/server/process_context.h b/include/envoy/server/process_context.h index 5118db1bf53d6..556941642d990 100644 --- a/include/envoy/server/process_context.h +++ b/include/envoy/server/process_context.h @@ -14,6 +14,8 @@ class ProcessObject { virtual ~ProcessObject() = default; }; +using ProcessObjectOptRef = absl::optional>; + /** * Context passed to filters to access resources from non-Envoy parts of the * process. @@ -28,6 +30,6 @@ class ProcessContext { virtual ProcessObject& get() const PURE; }; -using OptProcessContextRef = absl::optional>; +using ProcessContextOptRef = absl::optional>; } // namespace Envoy diff --git a/include/envoy/stats/scope.h b/include/envoy/stats/scope.h index 41ae185ced92a..29c9214a42548 100644 --- a/include/envoy/stats/scope.h +++ b/include/envoy/stats/scope.h @@ -19,9 +19,9 @@ class Histogram; class Scope; class NullGaugeImpl; -using OptionalCounter = absl::optional>; -using OptionalGauge = absl::optional>; -using OptionalHistogram = absl::optional>; +using CounterOptRef = absl::optional>; +using GaugeOptRef = absl::optional>; +using HistogramOptRef = absl::optional>; using ScopePtr = std::unique_ptr; using ScopeSharedPtr = std::shared_ptr; @@ -98,20 +98,20 @@ class Scope { * @param The name of the stat, obtained from the SymbolTable. * @return a reference to a counter within the scope's namespace, if it exists. */ - virtual OptionalCounter findCounter(StatName name) const PURE; + virtual CounterOptRef findCounter(StatName name) const PURE; /** * @param The name of the stat, obtained from the SymbolTable. * @return a reference to a gauge within the scope's namespace, if it exists. */ - virtual OptionalGauge findGauge(StatName name) const PURE; + virtual GaugeOptRef findGauge(StatName name) const PURE; /** * @param The name of the stat, obtained from the SymbolTable. * @return a reference to a histogram within the scope's namespace, if it * exists. */ - virtual OptionalHistogram findHistogram(StatName name) const PURE; + virtual HistogramOptRef findHistogram(StatName name) const PURE; /** * @return a reference to the symbol table. diff --git a/source/common/api/api_impl.cc b/source/common/api/api_impl.cc index e73c22bffd02f..bb245905e0cc8 100644 --- a/source/common/api/api_impl.cc +++ b/source/common/api/api_impl.cc @@ -11,7 +11,7 @@ namespace Api { Impl::Impl(Thread::ThreadFactory& thread_factory, Stats::Store& store, Event::TimeSystem& time_system, Filesystem::Instance& file_system, - const OptProcessContextRef& process_context) + const ProcessContextOptRef& process_context) : thread_factory_(thread_factory), store_(store), time_system_(time_system), file_system_(file_system), process_context_(process_context) {} diff --git a/source/common/api/api_impl.h b/source/common/api/api_impl.h index 6112843d97baa..e23428599ff82 100644 --- a/source/common/api/api_impl.h +++ b/source/common/api/api_impl.h @@ -18,7 +18,7 @@ class Impl : public Api { public: Impl(Thread::ThreadFactory& thread_factory, Stats::Store& store, Event::TimeSystem& time_system, Filesystem::Instance& file_system, - const OptProcessContextRef& process_context = absl::nullopt); + const ProcessContextOptRef& process_context = absl::nullopt); // Api::Api Event::DispatcherPtr allocateDispatcher() override; @@ -27,14 +27,14 @@ class Impl : public Api { Filesystem::Instance& fileSystem() override { return file_system_; } TimeSource& timeSource() override { return time_system_; } const Stats::Scope& rootScope() override { return store_; } - OptProcessContextRef processContext() override { return process_context_; } + ProcessContextOptRef processContext() override { return process_context_; } private: Thread::ThreadFactory& thread_factory_; Stats::Store& store_; Event::TimeSystem& time_system_; Filesystem::Instance& file_system_; - OptProcessContextRef process_context_; + ProcessContextOptRef process_context_; }; } // namespace Api diff --git a/source/common/network/addr_family_aware_socket_option_impl.cc b/source/common/network/addr_family_aware_socket_option_impl.cc index 093b88bd60e6a..60d33382c91a0 100644 --- a/source/common/network/addr_family_aware_socket_option_impl.cc +++ b/source/common/network/addr_family_aware_socket_option_impl.cc @@ -39,9 +39,8 @@ absl::optional getVersionFromSocket(const Socket& socket) { return absl::nullopt; } -absl::optional> -getOptionForSocket(const Socket& socket, SocketOptionImpl& ipv4_option, - SocketOptionImpl& ipv6_option) { +SocketOptionImplOptRef getOptionForSocket(const Socket& socket, SocketOptionImpl& ipv4_option, + SocketOptionImpl& ipv6_option) { auto version = getVersionFromSocket(socket); if (!version.has_value()) { return absl::nullopt; diff --git a/source/common/network/socket_option_impl.h b/source/common/network/socket_option_impl.h index 761399af9f40b..d8a047acb03fd 100644 --- a/source/common/network/socket_option_impl.h +++ b/source/common/network/socket_option_impl.h @@ -146,5 +146,7 @@ class SocketOptionImpl : public Socket::Option, Logger::Loggable value_; }; +using SocketOptionImplOptRef = absl::optional>; + } // namespace Network } // namespace Envoy diff --git a/source/common/stats/isolated_store_impl.h b/source/common/stats/isolated_store_impl.h index 8b3c58e84f04e..17bc71c540c12 100644 --- a/source/common/stats/isolated_store_impl.h +++ b/source/common/stats/isolated_store_impl.h @@ -28,6 +28,7 @@ template class IsolatedStatsCache { using CounterAllocator = std::function(StatName name)>; using GaugeAllocator = std::function(StatName, Gauge::ImportMode)>; using HistogramAllocator = std::function(StatName, Histogram::Unit)>; + using BaseOptConstRef = absl::optional>; IsolatedStatsCache(CounterAllocator alloc) : counter_alloc_(alloc) {} IsolatedStatsCache(GaugeAllocator alloc) : gauge_alloc_(alloc) {} @@ -79,7 +80,7 @@ template class IsolatedStatsCache { private: friend class IsolatedStoreImpl; - absl::optional> find(StatName name) const { + BaseOptConstRef find(StatName name) const { auto stat = stats_.find(name); if (stat == stats_.end()) { return absl::nullopt; @@ -113,9 +114,9 @@ class IsolatedStoreImpl : public StoreImpl { Histogram& histogram = histograms_.get(name, unit); return histogram; } - OptionalCounter findCounter(StatName name) const override { return counters_.find(name); } - OptionalGauge findGauge(StatName name) const override { return gauges_.find(name); } - OptionalHistogram findHistogram(StatName name) const override { return histograms_.find(name); } + CounterOptRef findCounter(StatName name) const override { return counters_.find(name); } + GaugeOptRef findGauge(StatName name) const override { return gauges_.find(name); } + HistogramOptRef findHistogram(StatName name) const override { return histograms_.find(name); } // Stats::Store std::vector counters() const override { return counters_.toVector(); } diff --git a/source/common/stats/scope_prefixer.cc b/source/common/stats/scope_prefixer.cc index e2a79b77a0dcb..6037805b7e127 100644 --- a/source/common/stats/scope_prefixer.cc +++ b/source/common/stats/scope_prefixer.cc @@ -44,11 +44,11 @@ Histogram& ScopePrefixer::histogramFromStatName(StatName name, Histogram::Unit u return scope_.histogramFromStatName(StatName(stat_name_storage.get()), unit); } -OptionalCounter ScopePrefixer::findCounter(StatName name) const { return scope_.findCounter(name); } +CounterOptRef ScopePrefixer::findCounter(StatName name) const { return scope_.findCounter(name); } -OptionalGauge ScopePrefixer::findGauge(StatName name) const { return scope_.findGauge(name); } +GaugeOptRef ScopePrefixer::findGauge(StatName name) const { return scope_.findGauge(name); } -OptionalHistogram ScopePrefixer::findHistogram(StatName name) const { +HistogramOptRef ScopePrefixer::findHistogram(StatName name) const { return scope_.findHistogram(name); } diff --git a/source/common/stats/scope_prefixer.h b/source/common/stats/scope_prefixer.h index 0e86b470e5c42..633406456f527 100644 --- a/source/common/stats/scope_prefixer.h +++ b/source/common/stats/scope_prefixer.h @@ -35,9 +35,9 @@ class ScopePrefixer : public Scope { return histogramFromStatName(storage.statName(), unit); } - OptionalCounter findCounter(StatName name) const override; - OptionalGauge findGauge(StatName name) const override; - OptionalHistogram findHistogram(StatName name) const override; + CounterOptRef findCounter(StatName name) const override; + GaugeOptRef findGauge(StatName name) const override; + HistogramOptRef findHistogram(StatName name) const override; const SymbolTable& constSymbolTable() const override { return scope_.constSymbolTable(); } SymbolTable& symbolTable() override { return scope_.symbolTable(); } diff --git a/source/common/stats/stat_merger.cc b/source/common/stats/stat_merger.cc index a53e32d93fbc8..aaa38a2b16355 100644 --- a/source/common/stats/stat_merger.cc +++ b/source/common/stats/stat_merger.cc @@ -35,7 +35,7 @@ void StatMerger::mergeGauges(const Protobuf::Map& gauges) StatNameManagedStorage storage(gauge.first, temp_scope_->symbolTable()); StatName stat_name = storage.statName(); - OptionalGauge gauge_opt = temp_scope_->findGauge(stat_name); + GaugeOptRef gauge_opt = temp_scope_->findGauge(stat_name); Gauge::ImportMode import_mode = Gauge::ImportMode::Uninitialized; if (gauge_opt) { diff --git a/source/common/stats/thread_local_store.cc b/source/common/stats/thread_local_store.cc index c35cd1e39f668..86b528a29d357 100644 --- a/source/common/stats/thread_local_store.cc +++ b/source/common/stats/thread_local_store.cc @@ -512,15 +512,15 @@ Histogram& ThreadLocalStoreImpl::ScopeImpl::histogramFromStatName(StatName name, return **central_ref; } -OptionalCounter ThreadLocalStoreImpl::ScopeImpl::findCounter(StatName name) const { +CounterOptRef ThreadLocalStoreImpl::ScopeImpl::findCounter(StatName name) const { return findStatLockHeld(name, central_cache_->counters_); } -OptionalGauge ThreadLocalStoreImpl::ScopeImpl::findGauge(StatName name) const { +GaugeOptRef ThreadLocalStoreImpl::ScopeImpl::findGauge(StatName name) const { return findStatLockHeld(name, central_cache_->gauges_); } -OptionalHistogram ThreadLocalStoreImpl::ScopeImpl::findHistogram(StatName name) const { +HistogramOptRef ThreadLocalStoreImpl::ScopeImpl::findHistogram(StatName name) const { auto iter = central_cache_->histograms_.find(name); if (iter == central_cache_->histograms_.end()) { return absl::nullopt; diff --git a/source/common/stats/thread_local_store.h b/source/common/stats/thread_local_store.h index 0f97f63ced9db..f45ae3f1dbd10 100644 --- a/source/common/stats/thread_local_store.h +++ b/source/common/stats/thread_local_store.h @@ -182,8 +182,8 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo const SymbolTable& constSymbolTable() const override { return alloc_.constSymbolTable(); } SymbolTable& symbolTable() override { return alloc_.symbolTable(); } const TagProducer& tagProducer() const { return *tag_producer_; } - OptionalCounter findCounter(StatName name) const override { - OptionalCounter found_counter; + CounterOptRef findCounter(StatName name) const override { + CounterOptRef found_counter; Thread::LockGuard lock(lock_); for (ScopeImpl* scope : scopes_) { found_counter = scope->findCounter(name); @@ -193,8 +193,8 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo } return absl::nullopt; } - OptionalGauge findGauge(StatName name) const override { - OptionalGauge found_gauge; + GaugeOptRef findGauge(StatName name) const override { + GaugeOptRef found_gauge; Thread::LockGuard lock(lock_); for (ScopeImpl* scope : scopes_) { found_gauge = scope->findGauge(name); @@ -204,8 +204,8 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo } return absl::nullopt; } - OptionalHistogram findHistogram(StatName name) const override { - OptionalHistogram found_histogram; + HistogramOptRef findHistogram(StatName name) const override { + HistogramOptRef found_histogram; Thread::LockGuard lock(lock_); for (ScopeImpl* scope : scopes_) { found_histogram = scope->findHistogram(name); @@ -306,9 +306,9 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo // NOTE: The find methods assume that `name` is fully-qualified. // Implementations will not add the scope prefix. - OptionalCounter findCounter(StatName name) const override; - OptionalGauge findGauge(StatName name) const override; - OptionalHistogram findHistogram(StatName name) const override; + CounterOptRef findCounter(StatName name) const override; + GaugeOptRef findGauge(StatName name) const override; + HistogramOptRef findHistogram(StatName name) const override; template using MakeStatFn = std::function(Allocator&, StatName name, diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index 507de51b6a4c8..18853ffd3751a 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -1260,7 +1260,7 @@ ClusterManagerImpl::ThreadLocalClusterManagerImpl::ClusterEntry::connPool( // Note: to simplify this, we assume that the factory is only called in the scope of this // function. Otherwise, we'd need to capture a few of these variables by value. - ConnPoolsContainer::ConnPools::OptPoolRef pool = + ConnPoolsContainer::ConnPools::PoolOptRef pool = container.pools_->getPool(priority, hash_key, [&]() { return parent_.parent_.factory_.allocateConnPool( parent_.thread_local_dispatcher_, host, priority, protocol, diff --git a/source/common/upstream/conn_pool_map.h b/source/common/upstream/conn_pool_map.h index 20127dbe401a4..041f619e0bfab 100644 --- a/source/common/upstream/conn_pool_map.h +++ b/source/common/upstream/conn_pool_map.h @@ -21,7 +21,7 @@ template class ConnPoolMap { public: using PoolFactory = std::function()>; using DrainedCb = std::function; - using OptPoolRef = absl::optional>; + using PoolOptRef = absl::optional>; ConnPoolMap(Event::Dispatcher& dispatcher, const HostConstSharedPtr& host, ResourcePriority priority); @@ -31,7 +31,7 @@ template class ConnPoolMap { * possible for this to fail if a limit on the number of pools allowed is reached. * @return The pool corresponding to `key`, or `absl::nullopt`. */ - OptPoolRef getPool(KEY_TYPE key, const PoolFactory& factory); + PoolOptRef getPool(KEY_TYPE key, const PoolFactory& factory); /** * @return the number of pools. diff --git a/source/common/upstream/conn_pool_map_impl.h b/source/common/upstream/conn_pool_map_impl.h index 19fa80ce4baa0..943e0b469c464 100644 --- a/source/common/upstream/conn_pool_map_impl.h +++ b/source/common/upstream/conn_pool_map_impl.h @@ -20,7 +20,7 @@ template ConnPoolMap -typename ConnPoolMap::OptPoolRef +typename ConnPoolMap::PoolOptRef ConnPoolMap::getPool(KEY_TYPE key, const PoolFactory& factory) { Common::AutoDebugRecursionChecker assert_not_in(recursion_checker_); // TODO(klarose): Consider how we will change the connection pool's configuration in the future. diff --git a/source/common/upstream/priority_conn_pool_map.h b/source/common/upstream/priority_conn_pool_map.h index 30636728d31b4..92b17174170da 100644 --- a/source/common/upstream/priority_conn_pool_map.h +++ b/source/common/upstream/priority_conn_pool_map.h @@ -16,7 +16,7 @@ template class PriorityConnPoolMap { using ConnPoolMapType = ConnPoolMap; using PoolFactory = typename ConnPoolMapType::PoolFactory; using DrainedCb = typename ConnPoolMapType::DrainedCb; - using OptPoolRef = typename ConnPoolMapType::OptPoolRef; + using PoolOptRef = typename ConnPoolMapType::PoolOptRef; PriorityConnPoolMap(Event::Dispatcher& dispatcher, const HostConstSharedPtr& host); ~PriorityConnPoolMap(); @@ -26,7 +26,7 @@ template class PriorityConnPoolMap { * is reached. * @return The pool corresponding to `key`, or `absl::nullopt`. */ - OptPoolRef getPool(ResourcePriority priority, KEY_TYPE key, const PoolFactory& factory); + PoolOptRef getPool(ResourcePriority priority, KEY_TYPE key, const PoolFactory& factory); /** * @return the number of pools across all priorities. diff --git a/source/common/upstream/priority_conn_pool_map_impl.h b/source/common/upstream/priority_conn_pool_map_impl.h index 7d6f537ff1a3d..8ece04d0272e0 100644 --- a/source/common/upstream/priority_conn_pool_map_impl.h +++ b/source/common/upstream/priority_conn_pool_map_impl.h @@ -19,7 +19,7 @@ template PriorityConnPoolMap::~PriorityConnPoolMap() = default; template -typename PriorityConnPoolMap::OptPoolRef +typename PriorityConnPoolMap::PoolOptRef PriorityConnPoolMap::getPool(ResourcePriority priority, KEY_TYPE key, const PoolFactory& factory) { size_t index = static_cast(priority); diff --git a/source/server/config_validation/server.h b/source/server/config_validation/server.h index 0e54368213193..3e2c4e2d35cc4 100644 --- a/source/server/config_validation/server.h +++ b/source/server/config_validation/server.h @@ -98,7 +98,7 @@ class ValidationInstance final : Logger::Loggable, Stats::Store& stats() override { return stats_store_; } Grpc::Context& grpcContext() override { return grpc_context_; } Http::Context& httpContext() override { return http_context_; } - OptProcessContextRef processContext() override { return absl::nullopt; } + ProcessContextOptRef processContext() override { return absl::nullopt; } ThreadLocal::Instance& threadLocal() override { return thread_local_; } const LocalInfo::LocalInfo& localInfo() const override { return *local_info_; } TimeSource& timeSource() override { return api_->timeSource(); } diff --git a/source/server/filter_chain_manager_impl.cc b/source/server/filter_chain_manager_impl.cc index 329f25c507450..21aeb41c2c358 100644 --- a/source/server/filter_chain_manager_impl.cc +++ b/source/server/filter_chain_manager_impl.cc @@ -115,7 +115,7 @@ ServerLifecycleNotifier& FilterChainFactoryContextImpl::lifecycleNotifier() { return parent_context_.lifecycleNotifier(); } -OptProcessContextRef FilterChainFactoryContextImpl::processContext() { +ProcessContextOptRef FilterChainFactoryContextImpl::processContext() { return parent_context_.processContext(); } diff --git a/source/server/filter_chain_manager_impl.h b/source/server/filter_chain_manager_impl.h index 7659acf5b1678..f4e47cbe19bbd 100644 --- a/source/server/filter_chain_manager_impl.h +++ b/source/server/filter_chain_manager_impl.h @@ -65,7 +65,7 @@ class FilterChainFactoryContextImpl : public Configuration::FilterChainFactoryCo ProtobufMessage::ValidationVisitor& messageValidationVisitor() override; Api::Api& api() override; ServerLifecycleNotifier& lifecycleNotifier() override; - OptProcessContextRef processContext() override; + ProcessContextOptRef processContext() override; Configuration::ServerFactoryContext& getServerFactoryContext() const override; Stats::Scope& listenerScope() override; diff --git a/source/server/http/admin.h b/source/server/http/admin.h index f14389026c7b8..fac51b4b23179 100644 --- a/source/server/http/admin.h +++ b/source/server/http/admin.h @@ -362,9 +362,7 @@ class AdminImpl : public Admin, return socket_; } - absl::optional> sharedSocket() const override { - return absl::nullopt; - } + Network::SocketOptRef sharedSocket() const override { return absl::nullopt; } private: Network::SocketSharedPtr socket_; diff --git a/source/server/listener_impl.cc b/source/server/listener_impl.cc index f89aef98bc5df..ae0ebc3ed8ca0 100644 --- a/source/server/listener_impl.cc +++ b/source/server/listener_impl.cc @@ -349,7 +349,7 @@ Api::Api& ListenerImpl::api() { return parent_.server_.api(); } ServerLifecycleNotifier& ListenerImpl::lifecycleNotifier() { return parent_.server_.lifecycleNotifier(); } -OptProcessContextRef ListenerImpl::processContext() { return parent_.server_.processContext(); } +ProcessContextOptRef ListenerImpl::processContext() { return parent_.server_.processContext(); } Configuration::ServerFactoryContext& ListenerImpl::getServerFactoryContext() const { return parent_.server_.serverFactoryContext(); } diff --git a/source/server/listener_impl.h b/source/server/listener_impl.h index 446e7f73218dc..eaa0c9d89063a 100644 --- a/source/server/listener_impl.h +++ b/source/server/listener_impl.h @@ -42,7 +42,7 @@ class ListenSocketFactoryImpl : public Network::ListenSocketFactory, /** * @return the socket shared by worker threads; otherwise return null. */ - absl::optional> sharedSocket() const override { + Network::SocketOptRef sharedSocket() const override { if (!reuse_port_) { ASSERT(socket_ != nullptr); return *socket_; @@ -176,7 +176,7 @@ class ListenerImpl : public Network::ListenerConfig, ProtobufMessage::ValidationVisitor& messageValidationVisitor() override; Api::Api& api() override; ServerLifecycleNotifier& lifecycleNotifier() override; - OptProcessContextRef processContext() override; + ProcessContextOptRef processContext() override; Configuration::ServerFactoryContext& getServerFactoryContext() const override; void ensureSocketOptions() { diff --git a/source/server/server.cc b/source/server/server.cc index d4efe15524348..67fbe10fc2387 100644 --- a/source/server/server.cc +++ b/source/server/server.cc @@ -60,7 +60,7 @@ InstanceImpl::InstanceImpl( time_source_(time_system), restarter_(restarter), start_time_(time(nullptr)), original_start_time_(start_time_), stats_store_(store), thread_local_(tls), api_(new Api::Impl(thread_factory, store, time_system, file_system, - process_context ? OptProcessContextRef(std::ref(*process_context)) + process_context ? ProcessContextOptRef(std::ref(*process_context)) : absl::nullopt)), dispatcher_(api_->allocateDispatcher()), singleton_manager_(new Singleton::ManagerImpl(api_->threadFactory())), diff --git a/source/server/server.h b/source/server/server.h index 039735604e398..acb1df0f0560d 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -219,7 +219,7 @@ class InstanceImpl final : Logger::Loggable, Stats::Store& stats() override { return stats_store_; } Grpc::Context& grpcContext() override { return grpc_context_; } Http::Context& httpContext() override { return http_context_; } - OptProcessContextRef processContext() override { return *process_context_; } + ProcessContextOptRef processContext() override { return *process_context_; } ThreadLocal::Instance& threadLocal() override { return thread_local_; } const LocalInfo::LocalInfo& localInfo() const override { return *local_info_; } TimeSource& timeSource() override { return time_source_; } diff --git a/test/common/stats/isolated_store_impl_test.cc b/test/common/stats/isolated_store_impl_test.cc index 2fba2a4f0592c..7e14e97a4230d 100644 --- a/test/common/stats/isolated_store_impl_test.cc +++ b/test/common/stats/isolated_store_impl_test.cc @@ -37,7 +37,7 @@ TEST_F(StatsIsolatedStoreImplTest, All) { EXPECT_EQ("scope1.c2", c2.tagExtractedName()); EXPECT_EQ(0, c1.tags().size()); EXPECT_EQ(0, c1.tags().size()); - OptionalCounter opt_counter = scope1->findCounter(c2.statName()); + CounterOptRef opt_counter = scope1->findCounter(c2.statName()); ASSERT_TRUE(opt_counter); EXPECT_EQ(&c2, &opt_counter->get()); StatName not_found = pool_.add("not_found"); @@ -60,7 +60,7 @@ TEST_F(StatsIsolatedStoreImplTest, All) { EXPECT_EQ("scope1.g2", g2.tagExtractedName()); EXPECT_EQ(0, g1.tags().size()); EXPECT_EQ(0, g2.tags().size()); - OptionalGauge opt_gauge = scope1->findGauge(g2.statName()); + GaugeOptRef opt_gauge = scope1->findGauge(g2.statName()); ASSERT_TRUE(opt_gauge); EXPECT_EQ(&g2, &opt_gauge->get()); EXPECT_FALSE(scope1->findGauge(not_found)); @@ -91,7 +91,7 @@ TEST_F(StatsIsolatedStoreImplTest, All) { EXPECT_EQ(0, h2.tags().size()); h1.recordValue(200); h2.recordValue(200); - OptionalHistogram opt_histogram = scope1->findHistogram(h2.statName()); + HistogramOptRef opt_histogram = scope1->findHistogram(h2.statName()); ASSERT_TRUE(opt_histogram); EXPECT_EQ(&h2, &opt_histogram->get()); EXPECT_FALSE(scope1->findHistogram(not_found)); diff --git a/test/common/stats/stat_merger_test.cc b/test/common/stats/stat_merger_test.cc index 4168bef2218ce..a3e883c1a910a 100644 --- a/test/common/stats/stat_merger_test.cc +++ b/test/common/stats/stat_merger_test.cc @@ -196,7 +196,7 @@ TEST_F(StatMergerThreadLocalTest, filterOutUninitializedGauges) { // We don't get "newgauge1" in the aggregated list, but we *do* get it if we try to // find it by name. - OptionalGauge find = store_.findGauge(g1.statName()); + GaugeOptRef find = store_.findGauge(g1.statName()); ASSERT_TRUE(find); EXPECT_EQ(&g1, &(find->get())); } diff --git a/test/common/upstream/conn_pool_map_impl_test.cc b/test/common/upstream/conn_pool_map_impl_test.cc index 059fec2ef0dae..6c4605cd96d24 100644 --- a/test/common/upstream/conn_pool_map_impl_test.cc +++ b/test/common/upstream/conn_pool_map_impl_test.cc @@ -108,7 +108,7 @@ TEST_F(ConnPoolMapImplTest, TestAddingTwoConnPoolsIncreasesSize) { TEST_F(ConnPoolMapImplTest, TestConnPoolReturnedMatchesCreated) { TestMapPtr test_map = makeTestMap(); - TestMap::OptPoolRef pool = test_map->getPool(1, getBasicFactory()); + TestMap::PoolOptRef pool = test_map->getPool(1, getBasicFactory()); EXPECT_EQ(&(pool.value().get()), mock_pools_[0]); } @@ -116,15 +116,15 @@ TEST_F(ConnPoolMapImplTest, TestConnSecondPoolReturnedMatchesCreated) { TestMapPtr test_map = makeTestMap(); test_map->getPool(1, getBasicFactory()); - TestMap::OptPoolRef pool = test_map->getPool(2, getBasicFactory()); + TestMap::PoolOptRef pool = test_map->getPool(2, getBasicFactory()); EXPECT_EQ(&(pool.value().get()), mock_pools_[1]); } TEST_F(ConnPoolMapImplTest, TestMultipleOfSameKeyReturnsOriginal) { TestMapPtr test_map = makeTestMap(); - TestMap::OptPoolRef pool1 = test_map->getPool(1, getBasicFactory()); - TestMap::OptPoolRef pool2 = test_map->getPool(2, getBasicFactory()); + TestMap::PoolOptRef pool1 = test_map->getPool(1, getBasicFactory()); + TestMap::PoolOptRef pool2 = test_map->getPool(2, getBasicFactory()); EXPECT_EQ(&(pool1.value().get()), &(test_map->getPool(1, getBasicFactory()).value().get())); EXPECT_EQ(&(pool2.value().get()), &(test_map->getPool(2, getBasicFactory()).value().get())); diff --git a/test/extensions/filters/network/zookeeper_proxy/filter_test.cc b/test/extensions/filters/network/zookeeper_proxy/filter_test.cc index 6520edeca8209..fb4d179e93041 100644 --- a/test/extensions/filters/network/zookeeper_proxy/filter_test.cc +++ b/test/extensions/filters/network/zookeeper_proxy/filter_test.cc @@ -495,7 +495,7 @@ class ZooKeeperFilterTest : public testing::Test { EXPECT_NE(absl::nullopt, findHistogram(histogram_name)); } - Stats::OptionalHistogram findHistogram(const std::string& name) { + Stats::HistogramOptRef findHistogram(const std::string& name) { Stats::StatNameManagedStorage storage(name, scope_.symbolTable()); return scope_.findHistogram(storage.statName()); } diff --git a/test/integration/fake_upstream.h b/test/integration/fake_upstream.h index 2bcd5b40cacea..6795b1fa39add 100644 --- a/test/integration/fake_upstream.h +++ b/test/integration/fake_upstream.h @@ -629,7 +629,7 @@ class FakeUpstream : Logger::Loggable, } Network::SocketSharedPtr getListenSocket() override { return socket_; } - absl::optional> sharedSocket() const override { + Network::SocketOptRef sharedSocket() const override { return *socket_; } diff --git a/test/integration/filters/eds_ready_filter.cc b/test/integration/filters/eds_ready_filter.cc index d24bb3d8a886b..9ce762f9a57a9 100644 --- a/test/integration/filters/eds_ready_filter.cc +++ b/test/integration/filters/eds_ready_filter.cc @@ -21,7 +21,7 @@ class EdsReadyFilter : public Http::PassThroughFilter { EdsReadyFilter(const Stats::Scope& root_scope, Stats::SymbolTable& symbol_table) : root_scope_(root_scope), stat_name_("cluster.cluster_0.membership_healthy", symbol_table) {} Http::FilterHeadersStatus decodeHeaders(Http::HeaderMap&, bool) override { - Stats::OptionalGauge gauge = root_scope_.findGauge(stat_name_.statName()); + Stats::GaugeOptRef gauge = root_scope_.findGauge(stat_name_.statName()); if (!gauge.has_value()) { decoder_callbacks_->sendLocalReply(Envoy::Http::Code::InternalServerError, "Couldn't find stat", nullptr, absl::nullopt, ""); diff --git a/test/integration/integration.h b/test/integration/integration.h index 725e87655fdd1..0a04837db44fd 100644 --- a/test/integration/integration.h +++ b/test/integration/integration.h @@ -366,7 +366,7 @@ class BaseIntegrationTest : protected Logger::Loggable { // The config for envoy start-up. ConfigHelper config_helper_; // The ProcessObject to use when constructing the envoy server. - absl::optional> process_object_{absl::nullopt}; + ProcessObjectOptRef process_object_{absl::nullopt}; // Steps that should be done before the envoy server starting. std::function on_server_ready_function_; diff --git a/test/integration/server.cc b/test/integration/server.cc index e451cad54a584..4f808ef583d35 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -55,7 +55,7 @@ IntegrationTestServerPtr IntegrationTestServer::create( std::function server_ready_function, std::function on_server_init_function, bool deterministic, Event::TestTimeSystem& time_system, Api::Api& api, bool defer_listener_finalization, - absl::optional> process_object, + ProcessObjectOptRef process_object, bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency) { IntegrationTestServerPtr server{ std::make_unique(time_system, api, config_path)}; @@ -81,7 +81,7 @@ void IntegrationTestServer::waitUntilListenersReady() { void IntegrationTestServer::start( const Network::Address::IpVersion version, std::function on_server_init_function, bool deterministic, bool defer_listener_finalization, - absl::optional> process_object, + ProcessObjectOptRef process_object, bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency) { ENVOY_LOG(info, "starting integration test server"); ASSERT(!thread_); @@ -164,7 +164,7 @@ void IntegrationTestServer::serverReady() { void IntegrationTestServer::threadRoutine( const Network::Address::IpVersion version, bool deterministic, - absl::optional> process_object, + ProcessObjectOptRef process_object, bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency) { OptionsImpl options(Server::createTestOptionsImpl(config_path_, "", version, allow_unknown_static_fields, @@ -197,7 +197,7 @@ void IntegrationTestServerImpl::createAndRunEnvoyServer( Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks, Thread::BasicLockable& access_log_lock, Server::ComponentFactory& component_factory, Runtime::RandomGeneratorPtr&& random_generator, - absl::optional> process_object) { + ProcessObjectOptRef process_object) { { Init::ManagerImpl init_manager{"Server"}; Stats::SymbolTablePtr symbol_table = Stats::SymbolTableCreator::makeSymbolTable(); diff --git a/test/integration/server.h b/test/integration/server.h index 9a1ca60e7525f..85559641b8583 100644 --- a/test/integration/server.h +++ b/test/integration/server.h @@ -112,15 +112,15 @@ class TestScopeWrapper : public Scope { return histogramFromStatName(storage.statName(), unit); } - OptionalCounter findCounter(StatName name) const override { + CounterOptRef findCounter(StatName name) const override { Thread::LockGuard lock(lock_); return wrapped_scope_->findCounter(name); } - OptionalGauge findGauge(StatName name) const override { + GaugeOptRef findGauge(StatName name) const override { Thread::LockGuard lock(lock_); return wrapped_scope_->findGauge(name); } - OptionalHistogram findHistogram(StatName name) const override { + HistogramOptRef findHistogram(StatName name) const override { Thread::LockGuard lock(lock_); return wrapped_scope_->findHistogram(name); } @@ -172,15 +172,15 @@ class TestIsolatedStoreImpl : public StoreRoot { Thread::LockGuard lock(lock_); return store_.histogram(name, unit); } - OptionalCounter findCounter(StatName name) const override { + CounterOptRef findCounter(StatName name) const override { Thread::LockGuard lock(lock_); return store_.findCounter(name); } - OptionalGauge findGauge(StatName name) const override { + GaugeOptRef findGauge(StatName name) const override { Thread::LockGuard lock(lock_); return store_.findGauge(name); } - OptionalHistogram findHistogram(StatName name) const override { + HistogramOptRef findHistogram(StatName name) const override { Thread::LockGuard lock(lock_); return store_.findHistogram(name); } @@ -237,7 +237,7 @@ class IntegrationTestServer : public Logger::Loggable, std::function on_server_init_function, bool deterministic, Event::TestTimeSystem& time_system, Api::Api& api, bool defer_listener_finalization = false, - absl::optional> process_object = absl::nullopt, + ProcessObjectOptRef process_object = absl::nullopt, bool allow_unknown_static_fields = false, bool reject_unknown_dynamic_fields = false, uint32_t concurrency = 1); // Note that the derived class is responsible for tearing down the server in its @@ -261,7 +261,7 @@ class IntegrationTestServer : public Logger::Loggable, void start(const Network::Address::IpVersion version, std::function on_server_init_function, bool deterministic, bool defer_listener_finalization, - absl::optional> process_object, + ProcessObjectOptRef process_object, bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency); @@ -330,7 +330,7 @@ class IntegrationTestServer : public Logger::Loggable, Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks, Thread::BasicLockable& access_log_lock, Server::ComponentFactory& component_factory, Runtime::RandomGeneratorPtr&& random_generator, - absl::optional> process_object) PURE; + ProcessObjectOptRef process_object) PURE; // Will be called by subclass on server thread when the server is ready to be accessed. The // server may not have been run yet, but all server access methods (server(), stat_store(), @@ -342,7 +342,7 @@ class IntegrationTestServer : public Logger::Loggable, * Runs the real server on a thread. */ void threadRoutine(const Network::Address::IpVersion version, bool deterministic, - absl::optional> process_object, + ProcessObjectOptRef process_object, bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency); @@ -386,7 +386,7 @@ class IntegrationTestServerImpl : public IntegrationTestServer { Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks, Thread::BasicLockable& access_log_lock, Server::ComponentFactory& component_factory, Runtime::RandomGeneratorPtr&& random_generator, - absl::optional> process_object) override; + ProcessObjectOptRef process_object) override; // Owned by this class. An owning pointer is not used because the actual allocation is done // on a stack in a non-main thread. diff --git a/test/mocks/api/mocks.h b/test/mocks/api/mocks.h index e631d715b9e81..c21f68e5ea51a 100644 --- a/test/mocks/api/mocks.h +++ b/test/mocks/api/mocks.h @@ -40,7 +40,7 @@ class MockApi : public Api { MOCK_METHOD0(fileSystem, Filesystem::Instance&()); MOCK_METHOD0(threadFactory, Thread::ThreadFactory&()); MOCK_METHOD0(rootScope, const Stats::Scope&()); - MOCK_METHOD0(processContext, OptProcessContextRef()); + MOCK_METHOD0(processContext, ProcessContextOptRef()); testing::NiceMock file_system_; Event::GlobalTimeSystem time_system_; diff --git a/test/mocks/network/mocks.h b/test/mocks/network/mocks.h index f31dd1627a546..48ae2140b5401 100644 --- a/test/mocks/network/mocks.h +++ b/test/mocks/network/mocks.h @@ -294,7 +294,7 @@ class MockListenSocketFactory : public ListenSocketFactory { MOCK_CONST_METHOD0(socketType, Network::Address::SocketType()); MOCK_CONST_METHOD0(localAddress, const Network::Address::InstanceConstSharedPtr&()); MOCK_METHOD0(getListenSocket, Network::SocketSharedPtr()); - MOCK_CONST_METHOD0(sharedSocket, absl::optional>()); + MOCK_CONST_METHOD0(sharedSocket, SocketOptRef()); }; class MockListenerConfig : public ListenerConfig { diff --git a/test/mocks/server/mocks.h b/test/mocks/server/mocks.h index c94e4deb13bd1..039b303dc18d1 100644 --- a/test/mocks/server/mocks.h +++ b/test/mocks/server/mocks.h @@ -399,7 +399,7 @@ class MockInstance : public Instance { MOCK_METHOD0(stats, Stats::Store&()); MOCK_METHOD0(grpcContext, Grpc::Context&()); MOCK_METHOD0(httpContext, Http::Context&()); - MOCK_METHOD0(processContext, absl::optional>()); + MOCK_METHOD0(processContext, ProcessContextOptRef()); MOCK_METHOD0(threadLocal, ThreadLocal::Instance&()); MOCK_CONST_METHOD0(localInfo, const LocalInfo::LocalInfo&()); MOCK_CONST_METHOD0(statsFlushInterval, std::chrono::milliseconds()); @@ -525,7 +525,7 @@ class MockFactoryContext : public virtual FactoryContext { Event::TestTimeSystem& timeSystem() { return time_system_; } Grpc::Context& grpcContext() override { return grpc_context_; } Http::Context& httpContext() override { return http_context_; } - MOCK_METHOD0(processContext, OptProcessContextRef()); + MOCK_METHOD0(processContext, ProcessContextOptRef()); MOCK_METHOD0(messageValidationVisitor, ProtobufMessage::ValidationVisitor&()); MOCK_METHOD0(api, Api::Api&()); diff --git a/test/mocks/stats/mocks.h b/test/mocks/stats/mocks.h index 6e9a1e4b1defe..75864c510b86e 100644 --- a/test/mocks/stats/mocks.h +++ b/test/mocks/stats/mocks.h @@ -289,9 +289,9 @@ class MockStore : public SymbolTableProvider, public StoreImpl { MOCK_METHOD2(histogram, Histogram&(const std::string&, Histogram::Unit)); MOCK_CONST_METHOD0(histograms, std::vector()); - MOCK_CONST_METHOD1(findCounter, OptionalCounter(StatName)); - MOCK_CONST_METHOD1(findGauge, OptionalGauge(StatName)); - MOCK_CONST_METHOD1(findHistogram, OptionalHistogram(StatName)); + MOCK_CONST_METHOD1(findCounter, CounterOptRef(StatName)); + MOCK_CONST_METHOD1(findGauge, GaugeOptRef(StatName)); + MOCK_CONST_METHOD1(findHistogram, HistogramOptRef(StatName)); Counter& counterFromStatName(StatName name) override { return counter(symbol_table_->toString(name)); From b37f8fda57e39747c82df49e77b4bce3070cf9a7 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Fri, 17 Jan 2020 13:54:52 -0800 Subject: [PATCH 2/5] fmt Signed-off-by: Jose Nino --- test/integration/fake_upstream.h | 4 +-- test/integration/server.cc | 27 +++++++++--------- test/integration/server.h | 48 +++++++++++++++----------------- 3 files changed, 37 insertions(+), 42 deletions(-) diff --git a/test/integration/fake_upstream.h b/test/integration/fake_upstream.h index 6795b1fa39add..c478bcbd377d0 100644 --- a/test/integration/fake_upstream.h +++ b/test/integration/fake_upstream.h @@ -629,9 +629,7 @@ class FakeUpstream : Logger::Loggable, } Network::SocketSharedPtr getListenSocket() override { return socket_; } - Network::SocketOptRef sharedSocket() const override { - return *socket_; - } + Network::SocketOptRef sharedSocket() const override { return *socket_; } private: Network::SocketSharedPtr socket_; diff --git a/test/integration/server.cc b/test/integration/server.cc index 4f808ef583d35..748eae363c989 100644 --- a/test/integration/server.cc +++ b/test/integration/server.cc @@ -55,8 +55,8 @@ IntegrationTestServerPtr IntegrationTestServer::create( std::function server_ready_function, std::function on_server_init_function, bool deterministic, Event::TestTimeSystem& time_system, Api::Api& api, bool defer_listener_finalization, - ProcessObjectOptRef process_object, - bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency) { + ProcessObjectOptRef process_object, bool allow_unknown_static_fields, + bool reject_unknown_dynamic_fields, uint32_t concurrency) { IntegrationTestServerPtr server{ std::make_unique(time_system, api, config_path)}; if (server_ready_function != nullptr) { @@ -78,11 +78,12 @@ void IntegrationTestServer::waitUntilListenersReady() { ENVOY_LOG(info, "listener wait complete"); } -void IntegrationTestServer::start( - const Network::Address::IpVersion version, std::function on_server_init_function, - bool deterministic, bool defer_listener_finalization, - ProcessObjectOptRef process_object, - bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency) { +void IntegrationTestServer::start(const Network::Address::IpVersion version, + std::function on_server_init_function, bool deterministic, + bool defer_listener_finalization, + ProcessObjectOptRef process_object, + bool allow_unknown_static_fields, + bool reject_unknown_dynamic_fields, uint32_t concurrency) { ENVOY_LOG(info, "starting integration test server"); ASSERT(!thread_); thread_ = api_.threadFactory().createThread( @@ -162,10 +163,11 @@ void IntegrationTestServer::serverReady() { server_set_.setReady(); } -void IntegrationTestServer::threadRoutine( - const Network::Address::IpVersion version, bool deterministic, - ProcessObjectOptRef process_object, - bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency) { +void IntegrationTestServer::threadRoutine(const Network::Address::IpVersion version, + bool deterministic, ProcessObjectOptRef process_object, + bool allow_unknown_static_fields, + bool reject_unknown_dynamic_fields, + uint32_t concurrency) { OptionsImpl options(Server::createTestOptionsImpl(config_path_, "", version, allow_unknown_static_fields, reject_unknown_dynamic_fields, concurrency)); @@ -196,8 +198,7 @@ void IntegrationTestServerImpl::createAndRunEnvoyServer( OptionsImpl& options, Event::TimeSystem& time_system, Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks, Thread::BasicLockable& access_log_lock, Server::ComponentFactory& component_factory, - Runtime::RandomGeneratorPtr&& random_generator, - ProcessObjectOptRef process_object) { + Runtime::RandomGeneratorPtr&& random_generator, ProcessObjectOptRef process_object) { { Init::ManagerImpl init_manager{"Server"}; Stats::SymbolTablePtr symbol_table = Stats::SymbolTableCreator::makeSymbolTable(); diff --git a/test/integration/server.h b/test/integration/server.h index 85559641b8583..778457ec36164 100644 --- a/test/integration/server.h +++ b/test/integration/server.h @@ -231,15 +231,13 @@ class IntegrationTestServer : public Logger::Loggable, public IntegrationTestServerStats, public Server::ComponentFactory { public: - static IntegrationTestServerPtr - create(const std::string& config_path, const Network::Address::IpVersion version, - std::function on_server_ready_function, - std::function on_server_init_function, bool deterministic, - Event::TestTimeSystem& time_system, Api::Api& api, - bool defer_listener_finalization = false, - ProcessObjectOptRef process_object = absl::nullopt, - bool allow_unknown_static_fields = false, bool reject_unknown_dynamic_fields = false, - uint32_t concurrency = 1); + static IntegrationTestServerPtr create( + const std::string& config_path, const Network::Address::IpVersion version, + std::function on_server_ready_function, + std::function on_server_init_function, bool deterministic, + Event::TestTimeSystem& time_system, Api::Api& api, bool defer_listener_finalization = false, + ProcessObjectOptRef process_object = absl::nullopt, bool allow_unknown_static_fields = false, + bool reject_unknown_dynamic_fields = false, uint32_t concurrency = 1); // Note that the derived class is responsible for tearing down the server in its // destructor. ~IntegrationTestServer() override; @@ -260,8 +258,7 @@ class IntegrationTestServer : public Logger::Loggable, void start(const Network::Address::IpVersion version, std::function on_server_init_function, bool deterministic, - bool defer_listener_finalization, - ProcessObjectOptRef process_object, + bool defer_listener_finalization, ProcessObjectOptRef process_object, bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, uint32_t concurrency); @@ -325,12 +322,12 @@ class IntegrationTestServer : public Logger::Loggable, // functions server(), stat_store(), and admin_address() may be called, but before the server // has been started. // The subclass is also responsible for tearing down this server in its destructor. - virtual void createAndRunEnvoyServer( - OptionsImpl& options, Event::TimeSystem& time_system, - Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks, - Thread::BasicLockable& access_log_lock, Server::ComponentFactory& component_factory, - Runtime::RandomGeneratorPtr&& random_generator, - ProcessObjectOptRef process_object) PURE; + virtual void createAndRunEnvoyServer(OptionsImpl& options, Event::TimeSystem& time_system, + Network::Address::InstanceConstSharedPtr local_address, + ListenerHooks& hooks, Thread::BasicLockable& access_log_lock, + Server::ComponentFactory& component_factory, + Runtime::RandomGeneratorPtr&& random_generator, + ProcessObjectOptRef process_object) PURE; // Will be called by subclass on server thread when the server is ready to be accessed. The // server may not have been run yet, but all server access methods (server(), stat_store(), @@ -342,9 +339,8 @@ class IntegrationTestServer : public Logger::Loggable, * Runs the real server on a thread. */ void threadRoutine(const Network::Address::IpVersion version, bool deterministic, - ProcessObjectOptRef process_object, - bool allow_unknown_static_fields, bool reject_unknown_dynamic_fields, - uint32_t concurrency); + ProcessObjectOptRef process_object, bool allow_unknown_static_fields, + bool reject_unknown_dynamic_fields, uint32_t concurrency); Event::TestTimeSystem& time_system_; Api::Api& api_; @@ -381,12 +377,12 @@ class IntegrationTestServerImpl : public IntegrationTestServer { Network::Address::InstanceConstSharedPtr admin_address() override { return admin_address_; } private: - void createAndRunEnvoyServer( - OptionsImpl& options, Event::TimeSystem& time_system, - Network::Address::InstanceConstSharedPtr local_address, ListenerHooks& hooks, - Thread::BasicLockable& access_log_lock, Server::ComponentFactory& component_factory, - Runtime::RandomGeneratorPtr&& random_generator, - ProcessObjectOptRef process_object) override; + void createAndRunEnvoyServer(OptionsImpl& options, Event::TimeSystem& time_system, + Network::Address::InstanceConstSharedPtr local_address, + ListenerHooks& hooks, Thread::BasicLockable& access_log_lock, + Server::ComponentFactory& component_factory, + Runtime::RandomGeneratorPtr&& random_generator, + ProcessObjectOptRef process_object) override; // Owned by this class. An owning pointer is not used because the actual allocation is done // on a stack in a non-main thread. From a9883adfb3ce8465087548bda00826475d4266b0 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Fri, 17 Jan 2020 14:24:38 -0800 Subject: [PATCH 3/5] update from master merge Signed-off-by: Jose Nino --- source/server/filter_chain_manager_impl.cc | 2 +- source/server/filter_chain_manager_impl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/server/filter_chain_manager_impl.cc b/source/server/filter_chain_manager_impl.cc index 7bd14a327a20f..4acc7be54a607 100644 --- a/source/server/filter_chain_manager_impl.cc +++ b/source/server/filter_chain_manager_impl.cc @@ -609,7 +609,7 @@ Api::Api& FactoryContextImpl::api() { return server_.api(); } ServerLifecycleNotifier& FactoryContextImpl::lifecycleNotifier() { return server_.lifecycleNotifier(); } -OptProcessContextRef FactoryContextImpl::processContext() { return server_.processContext(); } +ProcessContextOptRef FactoryContextImpl::processContext() { return server_.processContext(); } Configuration::ServerFactoryContext& FactoryContextImpl::getServerFactoryContext() const { return server_.serverFactoryContext(); } diff --git a/source/server/filter_chain_manager_impl.h b/source/server/filter_chain_manager_impl.h index b9c77f57acdaf..a10abe35f29cc 100644 --- a/source/server/filter_chain_manager_impl.h +++ b/source/server/filter_chain_manager_impl.h @@ -104,7 +104,7 @@ class FactoryContextImpl : public Configuration::FactoryContext { ProtobufMessage::ValidationVisitor& messageValidationVisitor() override; Api::Api& api() override; ServerLifecycleNotifier& lifecycleNotifier() override; - OptProcessContextRef processContext() override; + ProcessContextOptRef processContext() override; Configuration::ServerFactoryContext& getServerFactoryContext() const override; const envoy::config::core::v3::Metadata& listenerMetadata() const override; envoy::config::core::v3::TrafficDirection direction() const override; From e0b7af52001185ba2f7a07696b8703f7acfed153 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Mon, 27 Jan 2020 11:22:31 -0800 Subject: [PATCH 4/5] update const name Signed-off-by: Jose Nino --- include/envoy/stats/scope.h | 12 ++++++------ source/common/stats/isolated_store_impl.h | 6 +++--- source/common/stats/scope_prefixer.cc | 6 +++--- source/common/stats/scope_prefixer.h | 6 +++--- source/common/stats/stat_merger.cc | 2 +- source/common/stats/thread_local_store.cc | 6 +++--- source/common/stats/thread_local_store.h | 18 +++++++++--------- test/common/stats/isolated_store_impl_test.cc | 6 +++--- test/common/stats/stat_merger_test.cc | 2 +- .../network/zookeeper_proxy/filter_test.cc | 2 +- test/integration/filters/eds_ready_filter.cc | 2 +- test/integration/server.h | 12 ++++++------ test/mocks/stats/mocks.h | 6 +++--- 13 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/envoy/stats/scope.h b/include/envoy/stats/scope.h index 29c9214a42548..6a3a4aaf5d5f2 100644 --- a/include/envoy/stats/scope.h +++ b/include/envoy/stats/scope.h @@ -19,9 +19,9 @@ class Histogram; class Scope; class NullGaugeImpl; -using CounterOptRef = absl::optional>; -using GaugeOptRef = absl::optional>; -using HistogramOptRef = absl::optional>; +using CounterOptConstRef = absl::optional>; +using GaugeOptConstRef = absl::optional>; +using HistogramOptConstRef = absl::optional>; using ScopePtr = std::unique_ptr; using ScopeSharedPtr = std::shared_ptr; @@ -98,20 +98,20 @@ class Scope { * @param The name of the stat, obtained from the SymbolTable. * @return a reference to a counter within the scope's namespace, if it exists. */ - virtual CounterOptRef findCounter(StatName name) const PURE; + virtual CounterOptConstRef findCounter(StatName name) const PURE; /** * @param The name of the stat, obtained from the SymbolTable. * @return a reference to a gauge within the scope's namespace, if it exists. */ - virtual GaugeOptRef findGauge(StatName name) const PURE; + virtual GaugeOptConstRef findGauge(StatName name) const PURE; /** * @param The name of the stat, obtained from the SymbolTable. * @return a reference to a histogram within the scope's namespace, if it * exists. */ - virtual HistogramOptRef findHistogram(StatName name) const PURE; + virtual HistogramOptConstRef findHistogram(StatName name) const PURE; /** * @return a reference to the symbol table. diff --git a/source/common/stats/isolated_store_impl.h b/source/common/stats/isolated_store_impl.h index 17bc71c540c12..d550aed3896bd 100644 --- a/source/common/stats/isolated_store_impl.h +++ b/source/common/stats/isolated_store_impl.h @@ -114,9 +114,9 @@ class IsolatedStoreImpl : public StoreImpl { Histogram& histogram = histograms_.get(name, unit); return histogram; } - CounterOptRef findCounter(StatName name) const override { return counters_.find(name); } - GaugeOptRef findGauge(StatName name) const override { return gauges_.find(name); } - HistogramOptRef findHistogram(StatName name) const override { return histograms_.find(name); } + CounterOptConstRef findCounter(StatName name) const override { return counters_.find(name); } + GaugeOptConstRef findGauge(StatName name) const override { return gauges_.find(name); } + HistogramOptConstRef findHistogram(StatName name) const override { return histograms_.find(name); } // Stats::Store std::vector counters() const override { return counters_.toVector(); } diff --git a/source/common/stats/scope_prefixer.cc b/source/common/stats/scope_prefixer.cc index 6037805b7e127..e35eb26d9a216 100644 --- a/source/common/stats/scope_prefixer.cc +++ b/source/common/stats/scope_prefixer.cc @@ -44,11 +44,11 @@ Histogram& ScopePrefixer::histogramFromStatName(StatName name, Histogram::Unit u return scope_.histogramFromStatName(StatName(stat_name_storage.get()), unit); } -CounterOptRef ScopePrefixer::findCounter(StatName name) const { return scope_.findCounter(name); } +CounterOptConstRef ScopePrefixer::findCounter(StatName name) const { return scope_.findCounter(name); } -GaugeOptRef ScopePrefixer::findGauge(StatName name) const { return scope_.findGauge(name); } +GaugeOptConstRef ScopePrefixer::findGauge(StatName name) const { return scope_.findGauge(name); } -HistogramOptRef ScopePrefixer::findHistogram(StatName name) const { +HistogramOptConstRef ScopePrefixer::findHistogram(StatName name) const { return scope_.findHistogram(name); } diff --git a/source/common/stats/scope_prefixer.h b/source/common/stats/scope_prefixer.h index 633406456f527..4b28367a2a898 100644 --- a/source/common/stats/scope_prefixer.h +++ b/source/common/stats/scope_prefixer.h @@ -35,9 +35,9 @@ class ScopePrefixer : public Scope { return histogramFromStatName(storage.statName(), unit); } - CounterOptRef findCounter(StatName name) const override; - GaugeOptRef findGauge(StatName name) const override; - HistogramOptRef findHistogram(StatName name) const override; + CounterOptConstRef findCounter(StatName name) const override; + GaugeOptConstRef findGauge(StatName name) const override; + HistogramOptConstRef findHistogram(StatName name) const override; const SymbolTable& constSymbolTable() const override { return scope_.constSymbolTable(); } SymbolTable& symbolTable() override { return scope_.symbolTable(); } diff --git a/source/common/stats/stat_merger.cc b/source/common/stats/stat_merger.cc index aaa38a2b16355..eabce9d4f6cda 100644 --- a/source/common/stats/stat_merger.cc +++ b/source/common/stats/stat_merger.cc @@ -35,7 +35,7 @@ void StatMerger::mergeGauges(const Protobuf::Map& gauges) StatNameManagedStorage storage(gauge.first, temp_scope_->symbolTable()); StatName stat_name = storage.statName(); - GaugeOptRef gauge_opt = temp_scope_->findGauge(stat_name); + GaugeOptConstRef gauge_opt = temp_scope_->findGauge(stat_name); Gauge::ImportMode import_mode = Gauge::ImportMode::Uninitialized; if (gauge_opt) { diff --git a/source/common/stats/thread_local_store.cc b/source/common/stats/thread_local_store.cc index 86b528a29d357..43a20bc22dab0 100644 --- a/source/common/stats/thread_local_store.cc +++ b/source/common/stats/thread_local_store.cc @@ -512,15 +512,15 @@ Histogram& ThreadLocalStoreImpl::ScopeImpl::histogramFromStatName(StatName name, return **central_ref; } -CounterOptRef ThreadLocalStoreImpl::ScopeImpl::findCounter(StatName name) const { +CounterOptConstRef ThreadLocalStoreImpl::ScopeImpl::findCounter(StatName name) const { return findStatLockHeld(name, central_cache_->counters_); } -GaugeOptRef ThreadLocalStoreImpl::ScopeImpl::findGauge(StatName name) const { +GaugeOptConstRef ThreadLocalStoreImpl::ScopeImpl::findGauge(StatName name) const { return findStatLockHeld(name, central_cache_->gauges_); } -HistogramOptRef ThreadLocalStoreImpl::ScopeImpl::findHistogram(StatName name) const { +HistogramOptConstRef ThreadLocalStoreImpl::ScopeImpl::findHistogram(StatName name) const { auto iter = central_cache_->histograms_.find(name); if (iter == central_cache_->histograms_.end()) { return absl::nullopt; diff --git a/source/common/stats/thread_local_store.h b/source/common/stats/thread_local_store.h index f45ae3f1dbd10..ebe25f3645d5b 100644 --- a/source/common/stats/thread_local_store.h +++ b/source/common/stats/thread_local_store.h @@ -182,8 +182,8 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo const SymbolTable& constSymbolTable() const override { return alloc_.constSymbolTable(); } SymbolTable& symbolTable() override { return alloc_.symbolTable(); } const TagProducer& tagProducer() const { return *tag_producer_; } - CounterOptRef findCounter(StatName name) const override { - CounterOptRef found_counter; + CounterOptConstRef findCounter(StatName name) const override { + CounterOptConstRef found_counter; Thread::LockGuard lock(lock_); for (ScopeImpl* scope : scopes_) { found_counter = scope->findCounter(name); @@ -193,8 +193,8 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo } return absl::nullopt; } - GaugeOptRef findGauge(StatName name) const override { - GaugeOptRef found_gauge; + GaugeOptConstRef findGauge(StatName name) const override { + GaugeOptConstRef found_gauge; Thread::LockGuard lock(lock_); for (ScopeImpl* scope : scopes_) { found_gauge = scope->findGauge(name); @@ -204,8 +204,8 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo } return absl::nullopt; } - HistogramOptRef findHistogram(StatName name) const override { - HistogramOptRef found_histogram; + HistogramOptConstRef findHistogram(StatName name) const override { + HistogramOptConstRef found_histogram; Thread::LockGuard lock(lock_); for (ScopeImpl* scope : scopes_) { found_histogram = scope->findHistogram(name); @@ -306,9 +306,9 @@ class ThreadLocalStoreImpl : Logger::Loggable, public StoreRo // NOTE: The find methods assume that `name` is fully-qualified. // Implementations will not add the scope prefix. - CounterOptRef findCounter(StatName name) const override; - GaugeOptRef findGauge(StatName name) const override; - HistogramOptRef findHistogram(StatName name) const override; + CounterOptConstRef findCounter(StatName name) const override; + GaugeOptConstRef findGauge(StatName name) const override; + HistogramOptConstRef findHistogram(StatName name) const override; template using MakeStatFn = std::function(Allocator&, StatName name, diff --git a/test/common/stats/isolated_store_impl_test.cc b/test/common/stats/isolated_store_impl_test.cc index 7e14e97a4230d..a73d680d276d0 100644 --- a/test/common/stats/isolated_store_impl_test.cc +++ b/test/common/stats/isolated_store_impl_test.cc @@ -37,7 +37,7 @@ TEST_F(StatsIsolatedStoreImplTest, All) { EXPECT_EQ("scope1.c2", c2.tagExtractedName()); EXPECT_EQ(0, c1.tags().size()); EXPECT_EQ(0, c1.tags().size()); - CounterOptRef opt_counter = scope1->findCounter(c2.statName()); + CounterOptConstRef opt_counter = scope1->findCounter(c2.statName()); ASSERT_TRUE(opt_counter); EXPECT_EQ(&c2, &opt_counter->get()); StatName not_found = pool_.add("not_found"); @@ -60,7 +60,7 @@ TEST_F(StatsIsolatedStoreImplTest, All) { EXPECT_EQ("scope1.g2", g2.tagExtractedName()); EXPECT_EQ(0, g1.tags().size()); EXPECT_EQ(0, g2.tags().size()); - GaugeOptRef opt_gauge = scope1->findGauge(g2.statName()); + GaugeOptConstRef opt_gauge = scope1->findGauge(g2.statName()); ASSERT_TRUE(opt_gauge); EXPECT_EQ(&g2, &opt_gauge->get()); EXPECT_FALSE(scope1->findGauge(not_found)); @@ -91,7 +91,7 @@ TEST_F(StatsIsolatedStoreImplTest, All) { EXPECT_EQ(0, h2.tags().size()); h1.recordValue(200); h2.recordValue(200); - HistogramOptRef opt_histogram = scope1->findHistogram(h2.statName()); + HistogramOptConstRef opt_histogram = scope1->findHistogram(h2.statName()); ASSERT_TRUE(opt_histogram); EXPECT_EQ(&h2, &opt_histogram->get()); EXPECT_FALSE(scope1->findHistogram(not_found)); diff --git a/test/common/stats/stat_merger_test.cc b/test/common/stats/stat_merger_test.cc index a3e883c1a910a..540441fb75661 100644 --- a/test/common/stats/stat_merger_test.cc +++ b/test/common/stats/stat_merger_test.cc @@ -196,7 +196,7 @@ TEST_F(StatMergerThreadLocalTest, filterOutUninitializedGauges) { // We don't get "newgauge1" in the aggregated list, but we *do* get it if we try to // find it by name. - GaugeOptRef find = store_.findGauge(g1.statName()); + GaugeOptConstRef find = store_.findGauge(g1.statName()); ASSERT_TRUE(find); EXPECT_EQ(&g1, &(find->get())); } diff --git a/test/extensions/filters/network/zookeeper_proxy/filter_test.cc b/test/extensions/filters/network/zookeeper_proxy/filter_test.cc index fb4d179e93041..ad2b0efc96b24 100644 --- a/test/extensions/filters/network/zookeeper_proxy/filter_test.cc +++ b/test/extensions/filters/network/zookeeper_proxy/filter_test.cc @@ -495,7 +495,7 @@ class ZooKeeperFilterTest : public testing::Test { EXPECT_NE(absl::nullopt, findHistogram(histogram_name)); } - Stats::HistogramOptRef findHistogram(const std::string& name) { + Stats::HistogramOptConstRef findHistogram(const std::string& name) { Stats::StatNameManagedStorage storage(name, scope_.symbolTable()); return scope_.findHistogram(storage.statName()); } diff --git a/test/integration/filters/eds_ready_filter.cc b/test/integration/filters/eds_ready_filter.cc index 9ce762f9a57a9..3a8339d0ec448 100644 --- a/test/integration/filters/eds_ready_filter.cc +++ b/test/integration/filters/eds_ready_filter.cc @@ -21,7 +21,7 @@ class EdsReadyFilter : public Http::PassThroughFilter { EdsReadyFilter(const Stats::Scope& root_scope, Stats::SymbolTable& symbol_table) : root_scope_(root_scope), stat_name_("cluster.cluster_0.membership_healthy", symbol_table) {} Http::FilterHeadersStatus decodeHeaders(Http::HeaderMap&, bool) override { - Stats::GaugeOptRef gauge = root_scope_.findGauge(stat_name_.statName()); + Stats::GaugeOptConstRef gauge = root_scope_.findGauge(stat_name_.statName()); if (!gauge.has_value()) { decoder_callbacks_->sendLocalReply(Envoy::Http::Code::InternalServerError, "Couldn't find stat", nullptr, absl::nullopt, ""); diff --git a/test/integration/server.h b/test/integration/server.h index 492d52ff8acab..04591bc45a991 100644 --- a/test/integration/server.h +++ b/test/integration/server.h @@ -112,15 +112,15 @@ class TestScopeWrapper : public Scope { return histogramFromStatName(storage.statName(), unit); } - CounterOptRef findCounter(StatName name) const override { + CounterOptConstRef findCounter(StatName name) const override { Thread::LockGuard lock(lock_); return wrapped_scope_->findCounter(name); } - GaugeOptRef findGauge(StatName name) const override { + GaugeOptConstRef findGauge(StatName name) const override { Thread::LockGuard lock(lock_); return wrapped_scope_->findGauge(name); } - HistogramOptRef findHistogram(StatName name) const override { + HistogramOptConstRef findHistogram(StatName name) const override { Thread::LockGuard lock(lock_); return wrapped_scope_->findHistogram(name); } @@ -172,15 +172,15 @@ class TestIsolatedStoreImpl : public StoreRoot { Thread::LockGuard lock(lock_); return store_.histogram(name, unit); } - CounterOptRef findCounter(StatName name) const override { + CounterOptConstRef findCounter(StatName name) const override { Thread::LockGuard lock(lock_); return store_.findCounter(name); } - GaugeOptRef findGauge(StatName name) const override { + GaugeOptConstRef findGauge(StatName name) const override { Thread::LockGuard lock(lock_); return store_.findGauge(name); } - HistogramOptRef findHistogram(StatName name) const override { + HistogramOptConstRef findHistogram(StatName name) const override { Thread::LockGuard lock(lock_); return store_.findHistogram(name); } diff --git a/test/mocks/stats/mocks.h b/test/mocks/stats/mocks.h index ad0403f2c1a62..40f5bee6d1a08 100644 --- a/test/mocks/stats/mocks.h +++ b/test/mocks/stats/mocks.h @@ -289,9 +289,9 @@ class MockStore : public SymbolTableProvider, public StoreImpl { MOCK_METHOD(Histogram&, histogram, (const std::string&, Histogram::Unit)); MOCK_METHOD(std::vector, histograms, (), (const)); - MOCK_METHOD(CounterOptRef, findCounter, (StatName), (const)); - MOCK_METHOD(GaugeOptRef, findGauge, (StatName), (const)); - MOCK_METHOD(HistogramOptRef, findHistogram, (StatName), (const)); + MOCK_METHOD(CounterOptConstRef, findCounter, (StatName), (const)); + MOCK_METHOD(GaugeOptConstRef, findGauge, (StatName), (const)); + MOCK_METHOD(HistogramOptConstRef, findHistogram, (StatName), (const)); Counter& counterFromStatName(StatName name) override { return counter(symbol_table_->toString(name)); From ddbfb7ede44411b62068202e346a3965462fae8b Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Mon, 27 Jan 2020 11:41:17 -0800 Subject: [PATCH 5/5] fmt Signed-off-by: Jose Nino --- source/common/stats/isolated_store_impl.h | 4 +++- source/common/stats/scope_prefixer.cc | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/common/stats/isolated_store_impl.h b/source/common/stats/isolated_store_impl.h index d550aed3896bd..afe391c12ff56 100644 --- a/source/common/stats/isolated_store_impl.h +++ b/source/common/stats/isolated_store_impl.h @@ -116,7 +116,9 @@ class IsolatedStoreImpl : public StoreImpl { } CounterOptConstRef findCounter(StatName name) const override { return counters_.find(name); } GaugeOptConstRef findGauge(StatName name) const override { return gauges_.find(name); } - HistogramOptConstRef findHistogram(StatName name) const override { return histograms_.find(name); } + HistogramOptConstRef findHistogram(StatName name) const override { + return histograms_.find(name); + } // Stats::Store std::vector counters() const override { return counters_.toVector(); } diff --git a/source/common/stats/scope_prefixer.cc b/source/common/stats/scope_prefixer.cc index e35eb26d9a216..d4898af4f935e 100644 --- a/source/common/stats/scope_prefixer.cc +++ b/source/common/stats/scope_prefixer.cc @@ -44,7 +44,9 @@ Histogram& ScopePrefixer::histogramFromStatName(StatName name, Histogram::Unit u return scope_.histogramFromStatName(StatName(stat_name_storage.get()), unit); } -CounterOptConstRef ScopePrefixer::findCounter(StatName name) const { return scope_.findCounter(name); } +CounterOptConstRef ScopePrefixer::findCounter(StatName name) const { + return scope_.findCounter(name); +} GaugeOptConstRef ScopePrefixer::findGauge(StatName name) const { return scope_.findGauge(name); }