diff --git a/contrib/rocketmq_proxy/filters/network/source/config.cc b/contrib/rocketmq_proxy/filters/network/source/config.cc index dbb63f91a292a..25d630d6d1239 100644 --- a/contrib/rocketmq_proxy/filters/network/source/config.cc +++ b/contrib/rocketmq_proxy/filters/network/source/config.cc @@ -23,8 +23,8 @@ Network::FilterFactoryCb RocketmqProxyFilterConfigFactory::createFilterFactoryFr Server::Configuration::FactoryContext& context) { std::shared_ptr filter_config = std::make_shared(proto_config, context); return [filter_config, &context](Network::FilterManager& filter_manager) -> void { - filter_manager.addReadFilter( - std::make_shared(*filter_config, context.dispatcher().timeSource())); + filter_manager.addReadFilter(std::make_shared( + *filter_config, context.mainThreadDispatcher().timeSource())); }; } diff --git a/contrib/rocketmq_proxy/filters/network/test/active_message_test.cc b/contrib/rocketmq_proxy/filters/network/test/active_message_test.cc index 8b98a7be887b6..8ac6645efc7b2 100644 --- a/contrib/rocketmq_proxy/filters/network/test/active_message_test.cc +++ b/contrib/rocketmq_proxy/filters/network/test/active_message_test.cc @@ -24,7 +24,7 @@ class ActiveMessageTest : public testing::Test { ActiveMessageTest() : stats_(RocketmqFilterStats::generateStats("test.", store_)), config_(rocketmq_proxy_config_, factory_context_), - connection_manager_(config_, factory_context_.dispatcher().timeSource()) { + connection_manager_(config_, factory_context_.mainThreadDispatcher().timeSource()) { connection_manager_.initializeReadFilterCallbacks(filter_callbacks_); } diff --git a/contrib/rocketmq_proxy/filters/network/test/conn_manager_test.cc b/contrib/rocketmq_proxy/filters/network/test/conn_manager_test.cc index 30b783c4a0d98..e2c7d835c745c 100644 --- a/contrib/rocketmq_proxy/filters/network/test/conn_manager_test.cc +++ b/contrib/rocketmq_proxy/filters/network/test/conn_manager_test.cc @@ -54,11 +54,11 @@ class RocketmqConnectionManagerTest : public Event::TestUsingSimulatedTime, publ TestUtility::validate(proto_config_); } config_ = std::make_unique(proto_config_, factory_context_, stats_); - conn_manager_ = - std::make_unique(*config_, factory_context_.dispatcher().timeSource()); + conn_manager_ = std::make_unique( + *config_, factory_context_.mainThreadDispatcher().timeSource()); conn_manager_->initializeReadFilterCallbacks(filter_callbacks_); conn_manager_->onNewConnection(); - current_ = factory_context_.dispatcher().timeSource().monotonicTime(); + current_ = factory_context_.mainThreadDispatcher().timeSource().monotonicTime(); } void initializeCluster() { diff --git a/contrib/rocketmq_proxy/filters/network/test/router_test.cc b/contrib/rocketmq_proxy/filters/network/test/router_test.cc index 3cee446599e4e..681439d9212ae 100644 --- a/contrib/rocketmq_proxy/filters/network/test/router_test.cc +++ b/contrib/rocketmq_proxy/filters/network/test/router_test.cc @@ -25,7 +25,7 @@ class RocketmqRouterTestBase { cluster_info_(std::make_shared()) { context_.cluster_manager_.initializeThreadLocalClusters({"fake_cluster"}); conn_manager_ = - std::make_unique(config_, context_.dispatcher().timeSource()); + std::make_unique(config_, context_.mainThreadDispatcher().timeSource()); conn_manager_->initializeReadFilterCallbacks(filter_callbacks_); } diff --git a/contrib/sxg/filters/http/test/filter_test.cc b/contrib/sxg/filters/http/test/filter_test.cc index 0ec8fedcdd5fe..7853ac0590b9b 100644 --- a/contrib/sxg/filters/http/test/filter_test.cc +++ b/contrib/sxg/filters/http/test/filter_test.cc @@ -365,7 +365,7 @@ TEST_F(FilterTest, SdsDynamicGenericSecret) { NiceMock dispatcher; EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info)); EXPECT_CALL(secret_context, api()).WillRepeatedly(ReturnRef(*api)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); EXPECT_CALL(init_manager, add(_)) diff --git a/envoy/server/factory_context.h b/envoy/server/factory_context.h index 3624f32fe95b6..7a05d09b6ac20 100644 --- a/envoy/server/factory_context.h +++ b/envoy/server/factory_context.h @@ -52,7 +52,7 @@ class FactoryContextBase { * @return Event::Dispatcher& the main thread's dispatcher. This dispatcher should be used * for all singleton processing. */ - virtual Event::Dispatcher& dispatcher() PURE; + virtual Event::Dispatcher& mainThreadDispatcher() PURE; /** * @return Api::Api& a reference to the api object. diff --git a/envoy/server/health_checker_config.h b/envoy/server/health_checker_config.h index 00584f5176517..82f27123db8c3 100644 --- a/envoy/server/health_checker_config.h +++ b/envoy/server/health_checker_config.h @@ -28,7 +28,7 @@ class HealthCheckerFactoryContext { * @return Event::Dispatcher& the main thread's dispatcher. This dispatcher should be used * for all singleton processing. */ - virtual Event::Dispatcher& dispatcher() PURE; + virtual Event::Dispatcher& mainThreadDispatcher() PURE; /* * @return Upstream::HealthCheckEventLoggerPtr the health check event logger for the diff --git a/envoy/server/resource_monitor_config.h b/envoy/server/resource_monitor_config.h index 18e211e3801f1..9f680f44f8f2a 100644 --- a/envoy/server/resource_monitor_config.h +++ b/envoy/server/resource_monitor_config.h @@ -22,7 +22,7 @@ class ResourceMonitorFactoryContext { * @return Event::Dispatcher& the main thread's dispatcher. This dispatcher should be used * for all singleton processing. */ - virtual Event::Dispatcher& dispatcher() PURE; + virtual Event::Dispatcher& mainThreadDispatcher() PURE; /** * @return Server::Options& the command-line options that Envoy was started with. diff --git a/envoy/server/transport_socket_config.h b/envoy/server/transport_socket_config.h index 38308a9f1a642..703116ef250cc 100644 --- a/envoy/server/transport_socket_config.h +++ b/envoy/server/transport_socket_config.h @@ -62,7 +62,7 @@ class TransportSocketFactoryContext { /** * @return Event::Dispatcher& the main thread's dispatcher. */ - virtual Event::Dispatcher& dispatcher() PURE; + virtual Event::Dispatcher& mainThreadDispatcher() PURE; /** * @return Server::Options& the command-line options that Envoy was started with. diff --git a/source/common/router/config_impl.cc b/source/common/router/config_impl.cc index 68ed6e9096035..6f339aa3869ce 100644 --- a/source/common/router/config_impl.cc +++ b/source/common/router/config_impl.cc @@ -374,7 +374,7 @@ RouteEntryImplBase::RouteEntryImplBase(const VirtualHostImpl& vhost, vhost_.globalRouteConfig().maxDirectResponseBodySizeBytes())), per_filter_configs_(route.typed_per_filter_config(), optional_http_filters, factory_context, validator), - route_name_(route.name()), time_source_(factory_context.dispatcher().timeSource()) { + route_name_(route.name()), time_source_(factory_context.mainThreadDispatcher().timeSource()) { if (route.route().has_metadata_match()) { const auto filter_it = route.route().metadata_match().filter_metadata().find( Envoy::Config::MetadataFilters::get().ENVOY_LB); diff --git a/source/common/router/rds_impl.cc b/source/common/router/rds_impl.cc index 049e0f752fded..62f47d9221a11 100644 --- a/source/common/router/rds_impl.cc +++ b/source/common/router/rds_impl.cc @@ -309,9 +309,11 @@ void RdsRouteConfigProviderImpl::requestVirtualHostsUpdate( // execute the callback. still_alive shared_ptr will be deallocated when the current instance of // the RdsRouteConfigProviderImpl is deallocated; we rely on a weak_ptr to still_alive flag to // determine if the RdsRouteConfigProviderImpl instance is still valid. - factory_context_.dispatcher().post([this, maybe_still_alive = std::weak_ptr(still_alive_), - alias, &thread_local_dispatcher, - route_config_updated_cb]() -> void { + factory_context_.mainThreadDispatcher().post([this, + maybe_still_alive = + std::weak_ptr(still_alive_), + alias, &thread_local_dispatcher, + route_config_updated_cb]() -> void { if (maybe_still_alive.lock()) { subscription_->updateOnDemand(alias); config_update_callbacks_.push_back({alias, thread_local_dispatcher, route_config_updated_cb}); diff --git a/source/common/router/scoped_rds.cc b/source/common/router/scoped_rds.cc index eac4557b0ceb8..bbf3bec0e716c 100644 --- a/source/common/router/scoped_rds.cc +++ b/source/common/router/scoped_rds.cc @@ -487,8 +487,8 @@ void ScopedRdsConfigSubscription::onDemandRdsUpdate( std::shared_ptr scope_key, Event::Dispatcher& thread_local_dispatcher, Http::RouteConfigUpdatedCallback&& route_config_updated_cb, std::weak_ptr weak_subscription) { - factory_context_.dispatcher().post([this, &thread_local_dispatcher, scope_key, - route_config_updated_cb, weak_subscription]() { + factory_context_.mainThreadDispatcher().post([this, &thread_local_dispatcher, scope_key, + route_config_updated_cb, weak_subscription]() { // If the subscription has been destroyed, return immediately. if (!weak_subscription.lock()) { thread_local_dispatcher.post([route_config_updated_cb] { route_config_updated_cb(false); }); diff --git a/source/common/secret/sds_api.h b/source/common/secret/sds_api.h index f2ed3301ab61a..110e5acce70b6 100644 --- a/source/common/secret/sds_api.h +++ b/source/common/secret/sds_api.h @@ -140,9 +140,10 @@ class TlsCertificateSdsApi : public SdsApi, public TlsCertificateConfigProvider Config::Utility::checkLocalInfo("TlsCertificateSdsApi", secret_provider_context.localInfo()); return std::make_shared( sds_config, sds_config_name, secret_provider_context.clusterManager().subscriptionFactory(), - secret_provider_context.dispatcher().timeSource(), + secret_provider_context.mainThreadDispatcher().timeSource(), secret_provider_context.messageValidationVisitor(), secret_provider_context.stats(), - destructor_cb, secret_provider_context.dispatcher(), secret_provider_context.api()); + destructor_cb, secret_provider_context.mainThreadDispatcher(), + secret_provider_context.api()); } TlsCertificateSdsApi(const envoy::config::core::v3::ConfigSource& sds_config, @@ -226,9 +227,10 @@ class CertificateValidationContextSdsApi : public SdsApi, secret_provider_context.localInfo()); return std::make_shared( sds_config, sds_config_name, secret_provider_context.clusterManager().subscriptionFactory(), - secret_provider_context.dispatcher().timeSource(), + secret_provider_context.mainThreadDispatcher().timeSource(), secret_provider_context.messageValidationVisitor(), secret_provider_context.stats(), - destructor_cb, secret_provider_context.dispatcher(), secret_provider_context.api()); + destructor_cb, secret_provider_context.mainThreadDispatcher(), + secret_provider_context.api()); } CertificateValidationContextSdsApi(const envoy::config::core::v3::ConfigSource& sds_config, const std::string& sds_config_name, @@ -320,9 +322,10 @@ class TlsSessionTicketKeysSdsApi : public SdsApi, public TlsSessionTicketKeysCon secret_provider_context.localInfo()); return std::make_shared( sds_config, sds_config_name, secret_provider_context.clusterManager().subscriptionFactory(), - secret_provider_context.dispatcher().timeSource(), + secret_provider_context.mainThreadDispatcher().timeSource(), secret_provider_context.messageValidationVisitor(), secret_provider_context.stats(), - destructor_cb, secret_provider_context.dispatcher(), secret_provider_context.api()); + destructor_cb, secret_provider_context.mainThreadDispatcher(), + secret_provider_context.api()); } TlsSessionTicketKeysSdsApi(const envoy::config::core::v3::ConfigSource& sds_config, @@ -392,9 +395,10 @@ class GenericSecretSdsApi : public SdsApi, public GenericSecretConfigProvider { Config::Utility::checkLocalInfo("GenericSecretSdsApi", secret_provider_context.localInfo()); return std::make_shared( sds_config, sds_config_name, secret_provider_context.clusterManager().subscriptionFactory(), - secret_provider_context.dispatcher().timeSource(), + secret_provider_context.mainThreadDispatcher().timeSource(), secret_provider_context.messageValidationVisitor(), secret_provider_context.stats(), - destructor_cb, secret_provider_context.dispatcher(), secret_provider_context.api()); + destructor_cb, secret_provider_context.mainThreadDispatcher(), + secret_provider_context.api()); } GenericSecretSdsApi(const envoy::config::core::v3::ConfigSource& sds_config, diff --git a/source/common/upstream/BUILD b/source/common/upstream/BUILD index cca323285187e..236e917a50cce 100644 --- a/source/common/upstream/BUILD +++ b/source/common/upstream/BUILD @@ -87,6 +87,7 @@ envoy_cc_library( "//source/common/upstream:priority_conn_pool_map_impl_lib", "//source/common/upstream:upstream_lib", "//source/common/quic:quic_stat_names_lib", + "//source/server:factory_context_base_impl_lib", "@envoy_api//envoy/admin/v3:pkg_cc_proto", "@envoy_api//envoy/config/bootstrap/v3:pkg_cc_proto", "@envoy_api//envoy/config/cluster/v3:pkg_cc_proto", diff --git a/source/common/upstream/cluster_factory_impl.cc b/source/common/upstream/cluster_factory_impl.cc index 7425d9e546fb6..f3f2f2f06e77f 100644 --- a/source/common/upstream/cluster_factory_impl.cc +++ b/source/common/upstream/cluster_factory_impl.cc @@ -113,7 +113,7 @@ ClusterFactoryImplBase::selectDnsResolver(const envoy::config::cluster::v3::Clus resolvers.push_back(Network::Address::resolveProtoAddress(resolver_addr)); } } - return context.dispatcher().createDnsResolver(resolvers, dns_resolver_options); + return context.mainThreadDispatcher().createDnsResolver(resolvers, dns_resolver_options); } return context.dnsResolver(); @@ -127,7 +127,7 @@ ClusterFactoryImplBase::create(const envoy::config::cluster::v3::Cluster& cluste transport_factory_context = std::make_unique( context.admin(), context.sslContextManager(), *stats_scope, context.clusterManager(), - context.localInfo(), context.dispatcher(), context.stats(), + context.localInfo(), context.mainThreadDispatcher(), context.stats(), context.singletonManager(), context.threadLocal(), context.messageValidationVisitor(), context.api(), context.options()); @@ -141,13 +141,13 @@ ClusterFactoryImplBase::create(const envoy::config::cluster::v3::Cluster& cluste } else { new_cluster_pair.first->setHealthChecker(HealthCheckerFactory::create( cluster.health_checks()[0], *new_cluster_pair.first, context.runtime(), - context.dispatcher(), context.logManager(), context.messageValidationVisitor(), + context.mainThreadDispatcher(), context.logManager(), context.messageValidationVisitor(), context.api())); } } new_cluster_pair.first->setOutlierDetector(Outlier::DetectorImplFactory::createForCluster( - *new_cluster_pair.first, cluster, context.dispatcher(), context.runtime(), + *new_cluster_pair.first, cluster, context.mainThreadDispatcher(), context.runtime(), context.outlierEventLogger())); new_cluster_pair.first->setTransportFactoryContext(std::move(transport_factory_context)); diff --git a/source/common/upstream/cluster_factory_impl.h b/source/common/upstream/cluster_factory_impl.h index 1d7f3a6bc94cb..1ff81b8503285 100644 --- a/source/common/upstream/cluster_factory_impl.h +++ b/source/common/upstream/cluster_factory_impl.h @@ -74,7 +74,7 @@ class ClusterFactoryContextImpl : public ClusterFactoryContext { Network::DnsResolverSharedPtr dnsResolver() override { return dns_resolver_; } Ssl::ContextManager& sslContextManager() override { return ssl_context_manager_; } Runtime::Loader& runtime() override { return runtime_; } - Event::Dispatcher& dispatcher() override { return dispatcher_; } + Event::Dispatcher& mainThreadDispatcher() override { return dispatcher_; } AccessLog::AccessLogManager& logManager() override { return log_manager_; } const LocalInfo::LocalInfo& localInfo() const override { return local_info_; } const Server::Options& options() override { return options_; } diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index d8d7507fd7948..e41451f8658d9 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -1643,8 +1643,9 @@ void ClusterManagerImpl::ThreadLocalClusterManagerImpl::tcpConnPoolIsIdle( ClusterManagerPtr ProdClusterManagerFactory::clusterManagerFromProto( const envoy::config::bootstrap::v3::Bootstrap& bootstrap) { return ClusterManagerPtr{new ClusterManagerImpl( - bootstrap, *this, stats_, tls_, runtime_, local_info_, log_manager_, main_thread_dispatcher_, - admin_, validation_context_, api_, http_context_, grpc_context_, router_context_)}; + bootstrap, *this, stats_, tls_, context_.runtime(), context_.localInfo(), log_manager_, + context_.mainThreadDispatcher(), context_.admin(), validation_context_, context_.api(), + http_context_, grpc_context_, router_context_)}; } Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool( @@ -1655,7 +1656,8 @@ Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool( const Network::ConnectionSocket::OptionsSharedPtr& options, const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options, TimeSource& source, ClusterConnectivityState& state) { - if (protocols.size() == 3 && runtime_.snapshot().featureEnabled("upstream.use_http3", 100)) { + if (protocols.size() == 3 && + context_.runtime().snapshot().featureEnabled("upstream.use_http3", 100)) { ASSERT(contains(protocols, {Http::Protocol::Http11, Http::Protocol::Http2, Http::Protocol::Http3})); Http::AlternateProtocolsCacheSharedPtr alternate_protocols_cache; @@ -1667,9 +1669,9 @@ Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool( // TODO(RyanTheOptimist): Plumb an actual alternate protocols cache. Envoy::Http::ConnectivityGrid::ConnectivityOptions coptions{protocols}; return std::make_unique( - dispatcher, api_.randomGenerator(), host, priority, options, transport_socket_options, - state, source, alternate_protocols_cache, std::chrono::milliseconds(300), coptions, - quic_stat_names_, stats_); + dispatcher, context_.api().randomGenerator(), host, priority, options, + transport_socket_options, state, source, alternate_protocols_cache, + std::chrono::milliseconds(300), coptions, quic_stat_names_, stats_); #else // Should be blocked by configuration checking at an earlier point. NOT_REACHED_GCOVR_EXCL_LINE; @@ -1677,20 +1679,20 @@ Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool( } if (protocols.size() >= 2) { ASSERT(contains(protocols, {Http::Protocol::Http11, Http::Protocol::Http2})); - return std::make_unique(dispatcher, api_.randomGenerator(), host, - priority, options, - transport_socket_options, state); + return std::make_unique( + dispatcher, context_.api().randomGenerator(), host, priority, options, + transport_socket_options, state); } if (protocols.size() == 1 && protocols[0] == Http::Protocol::Http2 && - runtime_.snapshot().featureEnabled("upstream.use_http2", 100)) { - return Http::Http2::allocateConnPool(dispatcher, api_.randomGenerator(), host, priority, - options, transport_socket_options, state); + context_.runtime().snapshot().featureEnabled("upstream.use_http2", 100)) { + return Http::Http2::allocateConnPool(dispatcher, context_.api().randomGenerator(), host, + priority, options, transport_socket_options, state); } if (protocols.size() == 1 && protocols[0] == Http::Protocol::Http3 && - runtime_.snapshot().featureEnabled("upstream.use_http3", 100)) { + context_.runtime().snapshot().featureEnabled("upstream.use_http3", 100)) { #ifdef ENVOY_ENABLE_QUIC - return Http::Http3::allocateConnPool(dispatcher, api_.randomGenerator(), host, priority, - options, transport_socket_options, state, source, + return Http::Http3::allocateConnPool(dispatcher, context_.api().randomGenerator(), host, + priority, options, transport_socket_options, state, source, quic_stat_names_, stats_); #else UNREFERENCED_PARAMETER(source); @@ -1699,8 +1701,8 @@ Http::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateConnPool( #endif } ASSERT(protocols.size() == 1 && protocols[0] == Http::Protocol::Http11); - return Http::Http1::allocateConnPool(dispatcher, api_.randomGenerator(), host, priority, options, - transport_socket_options, state); + return Http::Http1::allocateConnPool(dispatcher, context_.api().randomGenerator(), host, priority, + options, transport_socket_options, state); } Tcp::ConnectionPool::InstancePtr ProdClusterManagerFactory::allocateTcpConnPool( @@ -1722,12 +1724,12 @@ std::pair ProdClusterManagerFactor const envoy::config::cluster::v3::Cluster& cluster, ClusterManager& cm, Outlier::EventLoggerSharedPtr outlier_event_logger, bool added_via_api) { return ClusterFactoryImplBase::create( - cluster, cm, stats_, tls_, dns_resolver_, ssl_context_manager_, runtime_, - main_thread_dispatcher_, log_manager_, local_info_, admin_, singleton_manager_, - outlier_event_logger, added_via_api, + cluster, cm, stats_, tls_, dns_resolver_, ssl_context_manager_, context_.runtime(), + context_.mainThreadDispatcher(), log_manager_, context_.localInfo(), admin_, + singleton_manager_, outlier_event_logger, added_via_api, added_via_api ? validation_context_.dynamicValidationVisitor() : validation_context_.staticValidationVisitor(), - api_, options_); + context_.api(), context_.options()); } CdsApiPtr diff --git a/source/common/upstream/cluster_manager_impl.h b/source/common/upstream/cluster_manager_impl.h index ce5480b1ea920..cf68e32fe16b0 100644 --- a/source/common/upstream/cluster_manager_impl.h +++ b/source/common/upstream/cluster_manager_impl.h @@ -36,6 +36,7 @@ #include "source/common/upstream/load_stats_reporter.h" #include "source/common/upstream/priority_conn_pool_map.h" #include "source/common/upstream/upstream_impl.h" +#include "source/server/factory_context_base_impl.h" namespace Envoy { namespace Upstream { @@ -54,12 +55,13 @@ class ProdClusterManagerFactory : public ClusterManagerFactory { Http::Context& http_context, Grpc::Context& grpc_context, Router::Context& router_context, AccessLog::AccessLogManager& log_manager, Singleton::Manager& singleton_manager, const Server::Options& options, Quic::QuicStatNames& quic_stat_names) - : main_thread_dispatcher_(main_thread_dispatcher), validation_context_(validation_context), - api_(api), http_context_(http_context), grpc_context_(grpc_context), - router_context_(router_context), admin_(admin), runtime_(runtime), stats_(stats), tls_(tls), - dns_resolver_(dns_resolver), ssl_context_manager_(ssl_context_manager), + : context_(options, main_thread_dispatcher, api, local_info, admin, runtime, + singleton_manager, validation_context.staticValidationVisitor(), stats, tls), + validation_context_(validation_context), http_context_(http_context), + grpc_context_(grpc_context), router_context_(router_context), admin_(admin), stats_(stats), + tls_(tls), dns_resolver_(dns_resolver), ssl_context_manager_(ssl_context_manager), local_info_(local_info), secret_manager_(secret_manager), log_manager_(log_manager), - singleton_manager_(singleton_manager), options_(options), quic_stat_names_(quic_stat_names), + singleton_manager_(singleton_manager), quic_stat_names_(quic_stat_names), alternate_protocols_cache_manager_factory_(singleton_manager, main_thread_dispatcher.timeSource(), tls_), alternate_protocols_cache_manager_(alternate_protocols_cache_manager_factory_.get()) {} @@ -90,14 +92,12 @@ class ProdClusterManagerFactory : public ClusterManagerFactory { Secret::SecretManager& secretManager() override { return secret_manager_; } protected: - Event::Dispatcher& main_thread_dispatcher_; + Server::FactoryContextBaseImpl context_; ProtobufMessage::ValidationContext& validation_context_; - Api::Api& api_; Http::Context& http_context_; Grpc::Context& grpc_context_; Router::Context& router_context_; Server::Admin& admin_; - Runtime::Loader& runtime_; Stats::Store& stats_; ThreadLocal::Instance& tls_; Network::DnsResolverSharedPtr dns_resolver_; @@ -106,7 +106,6 @@ class ProdClusterManagerFactory : public ClusterManagerFactory { Secret::SecretManager& secret_manager_; AccessLog::AccessLogManager& log_manager_; Singleton::Manager& singleton_manager_; - const Server::Options& options_; Quic::QuicStatNames& quic_stat_names_; Http::AlternateProtocolsCacheManagerFactoryImpl alternate_protocols_cache_manager_factory_; Http::AlternateProtocolsCacheManagerSharedPtr alternate_protocols_cache_manager_; diff --git a/source/common/upstream/eds.cc b/source/common/upstream/eds.cc index b25bdc07e5824..b95df7924a194 100644 --- a/source/common/upstream/eds.cc +++ b/source/common/upstream/eds.cc @@ -18,14 +18,14 @@ EdsClusterImpl::EdsClusterImpl( Server::Configuration::TransportSocketFactoryContextImpl& factory_context, Stats::ScopePtr&& stats_scope, bool added_via_api) : BaseDynamicClusterImpl(cluster, runtime, factory_context, std::move(stats_scope), - added_via_api, factory_context.dispatcher().timeSource()), + added_via_api, factory_context.mainThreadDispatcher().timeSource()), Envoy::Config::SubscriptionBase( factory_context.messageValidationVisitor(), "cluster_name"), local_info_(factory_context.localInfo()), cluster_name_(cluster.eds_cluster_config().service_name().empty() ? cluster.name() : cluster.eds_cluster_config().service_name()) { - Event::Dispatcher& dispatcher = factory_context.dispatcher(); + Event::Dispatcher& dispatcher = factory_context.mainThreadDispatcher(); assignment_timeout_ = dispatcher.createTimer([this]() -> void { onAssignmentTimeout(); }); const auto& eds_config = cluster.eds_cluster_config().eds_config(); if (eds_config.config_source_specifier_case() == diff --git a/source/common/upstream/health_checker_impl.cc b/source/common/upstream/health_checker_impl.cc index 2e7a1689b5191..09d8ebeca47e8 100644 --- a/source/common/upstream/health_checker_impl.cc +++ b/source/common/upstream/health_checker_impl.cc @@ -69,7 +69,7 @@ class HealthCheckerFactoryContextImpl : public Server::Configuration::HealthChec } Upstream::Cluster& cluster() override { return cluster_; } Envoy::Runtime::Loader& runtime() override { return runtime_; } - Event::Dispatcher& dispatcher() override { return dispatcher_; } + Event::Dispatcher& mainThreadDispatcher() override { return dispatcher_; } HealthCheckEventLoggerPtr eventLogger() override { return std::move(event_logger_); } ProtobufMessage::ValidationVisitor& messageValidationVisitor() override { return validation_visitor_; diff --git a/source/common/upstream/logical_dns_cluster.cc b/source/common/upstream/logical_dns_cluster.cc index ca9c9a809664b..c51bc3c94386d 100644 --- a/source/common/upstream/logical_dns_cluster.cc +++ b/source/common/upstream/logical_dns_cluster.cc @@ -49,13 +49,13 @@ LogicalDnsCluster::LogicalDnsCluster( Server::Configuration::TransportSocketFactoryContextImpl& factory_context, Stats::ScopePtr&& stats_scope, bool added_via_api) : ClusterImplBase(cluster, runtime, factory_context, std::move(stats_scope), added_via_api, - factory_context.dispatcher().timeSource()), + factory_context.mainThreadDispatcher().timeSource()), dns_resolver_(dns_resolver), dns_refresh_rate_ms_( std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(cluster, dns_refresh_rate, 5000))), respect_dns_ttl_(cluster.respect_dns_ttl()), resolve_timer_( - factory_context.dispatcher().createTimer([this]() -> void { startResolve(); })), + factory_context.mainThreadDispatcher().createTimer([this]() -> void { startResolve(); })), local_info_(factory_context.localInfo()), load_assignment_(convertPriority(cluster.load_assignment())) { failure_backoff_strategy_ = diff --git a/source/common/upstream/original_dst_cluster.cc b/source/common/upstream/original_dst_cluster.cc index 9cf6887aff530..00561a544a165 100644 --- a/source/common/upstream/original_dst_cluster.cc +++ b/source/common/upstream/original_dst_cluster.cc @@ -110,8 +110,8 @@ OriginalDstCluster::OriginalDstCluster( Server::Configuration::TransportSocketFactoryContextImpl& factory_context, Stats::ScopePtr&& stats_scope, bool added_via_api) : ClusterImplBase(config, runtime, factory_context, std::move(stats_scope), added_via_api, - factory_context.dispatcher().timeSource()), - dispatcher_(factory_context.dispatcher()), + factory_context.mainThreadDispatcher().timeSource()), + dispatcher_(factory_context.mainThreadDispatcher()), cleanup_interval_ms_( std::chrono::milliseconds(PROTOBUF_GET_MS_OR_DEFAULT(config, cleanup_interval, 5000))), cleanup_timer_(dispatcher_.createTimer([this]() -> void { cleanup(); })), diff --git a/source/common/upstream/static_cluster.cc b/source/common/upstream/static_cluster.cc index a8741f7a8f592..d8ce7b1a6ea02 100644 --- a/source/common/upstream/static_cluster.cc +++ b/source/common/upstream/static_cluster.cc @@ -12,7 +12,7 @@ StaticClusterImpl::StaticClusterImpl( Server::Configuration::TransportSocketFactoryContextImpl& factory_context, Stats::ScopePtr&& stats_scope, bool added_via_api) : ClusterImplBase(cluster, runtime, factory_context, std::move(stats_scope), added_via_api, - factory_context.dispatcher().timeSource()), + factory_context.mainThreadDispatcher().timeSource()), priority_state_manager_( new PriorityStateManager(*this, factory_context.localInfo(), nullptr)) { const envoy::config::endpoint::v3::ClusterLoadAssignment& cluster_load_assignment = @@ -20,7 +20,7 @@ StaticClusterImpl::StaticClusterImpl( overprovisioning_factor_ = PROTOBUF_GET_WRAPPED_OR_DEFAULT( cluster_load_assignment.policy(), overprovisioning_factor, kDefaultOverProvisioningFactor); - Event::Dispatcher& dispatcher = factory_context.dispatcher(); + Event::Dispatcher& dispatcher = factory_context.mainThreadDispatcher(); for (const auto& locality_lb_endpoint : cluster_load_assignment.endpoints()) { validateEndpointsForZoneAwareRouting(locality_lb_endpoint); diff --git a/source/common/upstream/strict_dns_cluster.cc b/source/common/upstream/strict_dns_cluster.cc index 0d03ea0a00f63..44cb3e83485a1 100644 --- a/source/common/upstream/strict_dns_cluster.cc +++ b/source/common/upstream/strict_dns_cluster.cc @@ -14,7 +14,7 @@ StrictDnsClusterImpl::StrictDnsClusterImpl( Server::Configuration::TransportSocketFactoryContextImpl& factory_context, Stats::ScopePtr&& stats_scope, bool added_via_api) : BaseDynamicClusterImpl(cluster, runtime, factory_context, std::move(stats_scope), - added_via_api, factory_context.dispatcher().timeSource()), + added_via_api, factory_context.mainThreadDispatcher().timeSource()), load_assignment_(cluster.load_assignment()), local_info_(factory_context.localInfo()), dns_resolver_(dns_resolver), dns_refresh_rate_ms_( @@ -37,8 +37,8 @@ StrictDnsClusterImpl::StrictDnsClusterImpl( const std::string& url = fmt::format("tcp://{}:{}", socket_address.address(), socket_address.port_value()); - resolve_targets.emplace_back(new ResolveTarget(*this, factory_context.dispatcher(), url, - locality_lb_endpoint, lb_endpoint)); + resolve_targets.emplace_back(new ResolveTarget(*this, factory_context.mainThreadDispatcher(), + url, locality_lb_endpoint, lb_endpoint)); } } resolve_targets_ = std::move(resolve_targets); diff --git a/source/common/upstream/upstream_impl.cc b/source/common/upstream/upstream_impl.cc index 2eec93be78914..6bb9a4ffc2cbf 100644 --- a/source/common/upstream/upstream_impl.cc +++ b/source/common/upstream/upstream_impl.cc @@ -677,12 +677,12 @@ class FactoryContextImpl : public Server::Configuration::CommonFactoryContext { FactoryContextImpl(Stats::Scope& stats_scope, Envoy::Runtime::Loader& runtime, Server::Configuration::TransportSocketFactoryContext& c) : admin_(c.admin()), stats_scope_(stats_scope), cluster_manager_(c.clusterManager()), - local_info_(c.localInfo()), dispatcher_(c.dispatcher()), runtime_(runtime), + local_info_(c.localInfo()), dispatcher_(c.mainThreadDispatcher()), runtime_(runtime), singleton_manager_(c.singletonManager()), tls_(c.threadLocal()), api_(c.api()), options_(c.options()), message_validation_visitor_(c.messageValidationVisitor()) {} Upstream::ClusterManager& clusterManager() override { return cluster_manager_; } - Event::Dispatcher& dispatcher() override { return dispatcher_; } + Event::Dispatcher& mainThreadDispatcher() override { return dispatcher_; } const Server::Options& options() override { return options_; } const LocalInfo::LocalInfo& localInfo() const override { return local_info_; } Envoy::Runtime::Loader& runtime() override { return runtime_; } @@ -1017,14 +1017,14 @@ ClusterImplBase::ClusterImplBase( local_cluster_(factory_context.clusterManager().localClusterName().value_or("") == cluster.name()), const_metadata_shared_pool_(Config::Metadata::getConstMetadataSharedPool( - factory_context.singletonManager(), factory_context.dispatcher())) { + factory_context.singletonManager(), factory_context.mainThreadDispatcher())) { factory_context.setInitManager(init_manager_); auto socket_factory = createTransportSocketFactory(cluster, factory_context); auto* raw_factory_pointer = socket_factory.get(); auto socket_matcher = std::make_unique( cluster.transport_socket_matches(), factory_context, socket_factory, *stats_scope); - auto& dispatcher = factory_context.dispatcher(); + auto& dispatcher = factory_context.mainThreadDispatcher(); info_ = std::shared_ptr( new ClusterInfoImpl(cluster, factory_context.clusterManager().bindConfig(), runtime, std::move(socket_matcher), std::move(stats_scope), added_via_api, diff --git a/source/extensions/access_loggers/wasm/config.cc b/source/extensions/access_loggers/wasm/config.cc index 721b0c062f46a..467398b7369ac 100644 --- a/source/extensions/access_loggers/wasm/config.cc +++ b/source/extensions/access_loggers/wasm/config.cc @@ -41,8 +41,8 @@ AccessLog::InstanceSharedPtr WasmAccessLogFactory::createAccessLogInstance( }; if (!Common::Wasm::createWasm(plugin, context.scope().createScope(""), context.clusterManager(), - context.initManager(), context.dispatcher(), context.api(), - context.lifecycleNotifier(), remote_data_provider_, + context.initManager(), context.mainThreadDispatcher(), + context.api(), context.lifecycleNotifier(), remote_data_provider_, std::move(callback))) { throw Common::Wasm::WasmException( fmt::format("Unable to create Wasm access log {}", plugin->name_)); diff --git a/source/extensions/bootstrap/wasm/config.cc b/source/extensions/bootstrap/wasm/config.cc index e87ddecebd34f..4f34f7e88dab4 100644 --- a/source/extensions/bootstrap/wasm/config.cc +++ b/source/extensions/bootstrap/wasm/config.cc @@ -32,8 +32,8 @@ void WasmServiceExtension::createWasm(Server::Configuration::ServerFactoryContex if (config_.singleton()) { // Return a Wasm VM which will be stored as a singleton by the Server. wasm_service_ = std::make_unique( - plugin, - Common::Wasm::getOrCreateThreadLocalPlugin(base_wasm, plugin, context.dispatcher())); + plugin, Common::Wasm::getOrCreateThreadLocalPlugin(base_wasm, plugin, + context.mainThreadDispatcher())); return; } // Per-thread WASM VM. @@ -49,8 +49,8 @@ void WasmServiceExtension::createWasm(Server::Configuration::ServerFactoryContex }; if (!Common::Wasm::createWasm(plugin, context.scope().createScope(""), context.clusterManager(), - context.initManager(), context.dispatcher(), context.api(), - context.lifecycleNotifier(), remote_data_provider_, + context.initManager(), context.mainThreadDispatcher(), + context.api(), context.lifecycleNotifier(), remote_data_provider_, std::move(callback))) { // NB: throw if we get a synchronous configuration failures as this is how such failures are // reported to xDS. diff --git a/source/extensions/clusters/aggregate/cluster.cc b/source/extensions/clusters/aggregate/cluster.cc index c7f21b5abdbd3..6e6b7ab77cab3 100644 --- a/source/extensions/clusters/aggregate/cluster.cc +++ b/source/extensions/clusters/aggregate/cluster.cc @@ -19,7 +19,7 @@ Cluster::Cluster(const envoy::config::cluster::v3::Cluster& cluster, Server::Configuration::TransportSocketFactoryContextImpl& factory_context, Stats::ScopePtr&& stats_scope, bool added_via_api) : Upstream::ClusterImplBase(cluster, runtime, factory_context, std::move(stats_scope), - added_via_api, factory_context.dispatcher().timeSource()), + added_via_api, factory_context.mainThreadDispatcher().timeSource()), cluster_manager_(cluster_manager), runtime_(runtime), random_(random), clusters_(std::make_shared(config.clusters().begin(), config.clusters().end())) {} diff --git a/source/extensions/clusters/dynamic_forward_proxy/cluster.cc b/source/extensions/clusters/dynamic_forward_proxy/cluster.cc index 2bef1a7f333b8..62209fbd8b98c 100644 --- a/source/extensions/clusters/dynamic_forward_proxy/cluster.cc +++ b/source/extensions/clusters/dynamic_forward_proxy/cluster.cc @@ -22,7 +22,8 @@ Cluster::Cluster( Server::Configuration::TransportSocketFactoryContextImpl& factory_context, Stats::ScopePtr&& stats_scope, bool added_via_api) : Upstream::BaseDynamicClusterImpl(cluster, runtime, factory_context, std::move(stats_scope), - added_via_api, factory_context.dispatcher().timeSource()), + added_via_api, + factory_context.mainThreadDispatcher().timeSource()), dns_cache_manager_(cache_manager_factory.get()), dns_cache_(dns_cache_manager_->getCache(config.dns_cache_config())), update_callbacks_handle_(dns_cache_->addUpdateCallbacks(*this)), local_info_(local_info) {} diff --git a/source/extensions/clusters/redis/redis_cluster.cc b/source/extensions/clusters/redis/redis_cluster.cc index 59d6f7ad0d3ca..e497a62a9ccf7 100644 --- a/source/extensions/clusters/redis/redis_cluster.cc +++ b/source/extensions/clusters/redis/redis_cluster.cc @@ -25,7 +25,8 @@ RedisCluster::RedisCluster( Stats::ScopePtr&& stats_scope, bool added_via_api, ClusterSlotUpdateCallBackSharedPtr lb_factory) : Upstream::BaseDynamicClusterImpl(cluster, runtime, factory_context, std::move(stats_scope), - added_via_api, factory_context.dispatcher().timeSource()), + added_via_api, + factory_context.mainThreadDispatcher().timeSource()), cluster_manager_(cluster_manager), cluster_refresh_rate_(std::chrono::milliseconds( PROTOBUF_GET_MS_OR_DEFAULT(redis_cluster, cluster_refresh_rate, 5000))), @@ -37,7 +38,7 @@ RedisCluster::RedisCluster( PROTOBUF_GET_WRAPPED_OR_DEFAULT(redis_cluster, redirect_refresh_threshold, 5)), failure_refresh_threshold_(redis_cluster.failure_refresh_threshold()), host_degraded_refresh_threshold_(redis_cluster.host_degraded_refresh_threshold()), - dispatcher_(factory_context.dispatcher()), dns_resolver_(std::move(dns_resolver)), + dispatcher_(factory_context.mainThreadDispatcher()), dns_resolver_(std::move(dns_resolver)), dns_lookup_family_(Upstream::getDnsLookupFamilyFromCluster(cluster)), load_assignment_(cluster.load_assignment()), local_info_(factory_context.localInfo()), random_(api.randomGenerator()), redis_discovery_session_(*this, redis_client_factory), @@ -48,7 +49,7 @@ RedisCluster::RedisCluster( NetworkFilters::RedisProxy::ProtocolOptionsConfigImpl::authPassword(info(), api)), cluster_name_(cluster.name()), refresh_manager_(Common::Redis::getClusterRefreshManager( - factory_context.singletonManager(), factory_context.dispatcher(), + factory_context.singletonManager(), factory_context.mainThreadDispatcher(), factory_context.clusterManager(), factory_context.api().timeSource())), registration_handle_(refresh_manager_->registerCluster( cluster_name_, redirect_refresh_interval_, redirect_refresh_threshold_, diff --git a/source/extensions/common/dynamic_forward_proxy/dns_cache_impl.cc b/source/extensions/common/dynamic_forward_proxy/dns_cache_impl.cc index edadd96bafd95..15f1fa6a9b07a 100644 --- a/source/extensions/common/dynamic_forward_proxy/dns_cache_impl.cc +++ b/source/extensions/common/dynamic_forward_proxy/dns_cache_impl.cc @@ -19,7 +19,7 @@ namespace DynamicForwardProxy { DnsCacheImpl::DnsCacheImpl( Server::Configuration::FactoryContextBase& context, const envoy::extensions::common::dynamic_forward_proxy::v3::DnsCacheConfig& config) - : main_thread_dispatcher_(context.dispatcher()), + : main_thread_dispatcher_(context.mainThreadDispatcher()), dns_lookup_family_(Upstream::getDnsLookupFamilyFromEnum(config.dns_lookup_family())), resolver_(selectDnsResolver(config, main_thread_dispatcher_)), tls_slot_(context.threadLocal()), diff --git a/source/extensions/filters/http/adaptive_concurrency/config.cc b/source/extensions/filters/http/adaptive_concurrency/config.cc index 5abc39bf6fd97..ed2182bafcde4 100644 --- a/source/extensions/filters/http/adaptive_concurrency/config.cc +++ b/source/extensions/filters/http/adaptive_concurrency/config.cc @@ -25,7 +25,7 @@ Http::FilterFactoryCb AdaptiveConcurrencyFilterFactory::createFilterFactoryFromP auto gradient_controller_config = Controller::GradientControllerConfig(config.gradient_controller_config(), context.runtime()); controller = std::make_shared( - std::move(gradient_controller_config), context.dispatcher(), context.runtime(), + std::move(gradient_controller_config), context.mainThreadDispatcher(), context.runtime(), acc_stats_prefix + "gradient_controller.", context.scope(), context.api().randomGenerator(), context.timeSource()); diff --git a/source/extensions/filters/http/alternate_protocols_cache/config.cc b/source/extensions/filters/http/alternate_protocols_cache/config.cc index 61327b29b1d92..dea1f9904b0a5 100644 --- a/source/extensions/filters/http/alternate_protocols_cache/config.cc +++ b/source/extensions/filters/http/alternate_protocols_cache/config.cc @@ -16,9 +16,11 @@ Http::FilterFactoryCb AlternateProtocolsCacheFilterFactory::createFilterFactoryF proto_config, const std::string&, Server::Configuration::FactoryContext& context) { Http::AlternateProtocolsCacheManagerFactoryImpl alternate_protocol_cache_manager_factory( - context.singletonManager(), context.dispatcher().timeSource(), context.threadLocal()); - FilterConfigSharedPtr filter_config(std::make_shared( - proto_config, alternate_protocol_cache_manager_factory, context.dispatcher().timeSource())); + context.singletonManager(), context.mainThreadDispatcher().timeSource(), + context.threadLocal()); + FilterConfigSharedPtr filter_config( + std::make_shared(proto_config, alternate_protocol_cache_manager_factory, + context.mainThreadDispatcher().timeSource())); return [filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void { callbacks.addStreamEncoderFilter(std::make_shared(filter_config)); }; diff --git a/source/extensions/filters/http/aws_lambda/config.cc b/source/extensions/filters/http/aws_lambda/config.cc index a538f07847ddd..a3b1838ff1949 100644 --- a/source/extensions/filters/http/aws_lambda/config.cc +++ b/source/extensions/filters/http/aws_lambda/config.cc @@ -47,7 +47,8 @@ Http::FilterFactoryCb AwsLambdaFilterFactory::createFilterFactoryFromProtoTyped( } const std::string region = arn->region(); auto signer = std::make_shared( - service_name, region, std::move(credentials_provider), context.dispatcher().timeSource()); + service_name, region, std::move(credentials_provider), + context.mainThreadDispatcher().timeSource()); FilterSettings filter_settings{*arn, getInvocationMode(proto_config), proto_config.payload_passthrough()}; diff --git a/source/extensions/filters/http/aws_request_signing/config.cc b/source/extensions/filters/http/aws_request_signing/config.cc index 02408ec90a091..0d2e9bc97c1f4 100644 --- a/source/extensions/filters/http/aws_request_signing/config.cc +++ b/source/extensions/filters/http/aws_request_signing/config.cc @@ -23,7 +23,7 @@ Http::FilterFactoryCb AwsRequestSigningFilterFactory::createFilterFactoryFromPro context.api(), Extensions::Common::Aws::Utility::metadataFetcher); auto signer = std::make_unique( config.service_name(), config.region(), credentials_provider, - context.dispatcher().timeSource()); + context.mainThreadDispatcher().timeSource()); auto filter_config = std::make_shared(std::move(signer), stats_prefix, context.scope(), diff --git a/source/extensions/filters/http/dynamo/config.cc b/source/extensions/filters/http/dynamo/config.cc index 0850dc9b70836..eaf33d18e73f2 100644 --- a/source/extensions/filters/http/dynamo/config.cc +++ b/source/extensions/filters/http/dynamo/config.cc @@ -19,7 +19,7 @@ Http::FilterFactoryCb DynamoFilterConfig::createFilterFactoryFromProtoTyped( auto stats = std::make_shared(context.scope(), stats_prefix); return [&context, stats](Http::FilterChainFactoryCallbacks& callbacks) -> void { callbacks.addStreamFilter(std::make_shared( - context.runtime(), stats, context.dispatcher().timeSource())); + context.runtime(), stats, context.mainThreadDispatcher().timeSource())); }; } diff --git a/source/extensions/filters/http/health_check/config.cc b/source/extensions/filters/http/health_check/config.cc index faad4fce070c3..3cf363721e65b 100644 --- a/source/extensions/filters/http/health_check/config.cc +++ b/source/extensions/filters/http/health_check/config.cc @@ -33,7 +33,7 @@ Http::FilterFactoryCb HealthCheckFilterConfig::createFilterFactoryFromProtoTyped HealthCheckCacheManagerSharedPtr cache_manager; if (cache_time_ms > 0) { cache_manager = std::make_shared( - context.dispatcher(), std::chrono::milliseconds(cache_time_ms)); + context.mainThreadDispatcher(), std::chrono::milliseconds(cache_time_ms)); } ClusterMinHealthyPercentagesConstSharedPtr cluster_min_healthy_percentages; diff --git a/source/extensions/filters/http/jwt_authn/filter_config.cc b/source/extensions/filters/http/jwt_authn/filter_config.cc index 8d2874290678f..8ead6c17fd52a 100644 --- a/source/extensions/filters/http/jwt_authn/filter_config.cc +++ b/source/extensions/filters/http/jwt_authn/filter_config.cc @@ -15,7 +15,7 @@ FilterConfigImpl::FilterConfigImpl( envoy::extensions::filters::http::jwt_authn::v3::JwtAuthentication proto_config, const std::string& stats_prefix, Server::Configuration::FactoryContext& context) : proto_config_(std::move(proto_config)), stats_(generateStats(stats_prefix, context.scope())), - cm_(context.clusterManager()), time_source_(context.dispatcher().timeSource()) { + cm_(context.clusterManager()), time_source_(context.mainThreadDispatcher().timeSource()) { ENVOY_LOG(debug, "Loaded JwtAuthConfig: {}", proto_config_.DebugString()); diff --git a/source/extensions/filters/http/jwt_authn/jwks_async_fetcher.cc b/source/extensions/filters/http/jwt_authn/jwks_async_fetcher.cc index 9521fc214cb63..5e1acb2763705 100644 --- a/source/extensions/filters/http/jwt_authn/jwks_async_fetcher.cc +++ b/source/extensions/filters/http/jwt_authn/jwks_async_fetcher.cc @@ -28,7 +28,8 @@ JwksAsyncFetcher::JwksAsyncFetcher(const RemoteJwks& remote_jwks, return; } - cache_duration_timer_ = context_.dispatcher().createTimer([this]() -> void { fetch(); }); + cache_duration_timer_ = + context_.mainThreadDispatcher().createTimer([this]() -> void { fetch(); }); // For fast_listener, just trigger a fetch, not register with init_manager. if (remote_jwks_.async_fetch().fast_listener()) { diff --git a/source/extensions/filters/http/local_ratelimit/config.cc b/source/extensions/filters/http/local_ratelimit/config.cc index 15c7107276960..d70e8f8aac49c 100644 --- a/source/extensions/filters/http/local_ratelimit/config.cc +++ b/source/extensions/filters/http/local_ratelimit/config.cc @@ -16,7 +16,8 @@ Http::FilterFactoryCb LocalRateLimitFilterConfig::createFilterFactoryFromProtoTy const envoy::extensions::filters::http::local_ratelimit::v3::LocalRateLimit& proto_config, const std::string&, Server::Configuration::FactoryContext& context) { FilterConfigSharedPtr filter_config = std::make_shared( - proto_config, context.localInfo(), context.dispatcher(), context.scope(), context.runtime()); + proto_config, context.localInfo(), context.mainThreadDispatcher(), context.scope(), + context.runtime()); return [filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void { callbacks.addStreamFilter(std::make_shared(filter_config)); }; @@ -27,7 +28,7 @@ LocalRateLimitFilterConfig::createRouteSpecificFilterConfigTyped( const envoy::extensions::filters::http::local_ratelimit::v3::LocalRateLimit& proto_config, Server::Configuration::ServerFactoryContext& context, ProtobufMessage::ValidationVisitor&) { return std::make_shared(proto_config, context.localInfo(), - context.dispatcher(), context.scope(), + context.mainThreadDispatcher(), context.scope(), context.runtime(), true); } diff --git a/source/extensions/filters/http/lua/config.cc b/source/extensions/filters/http/lua/config.cc index 6ed6ba6ddcd98..822eecc2c773a 100644 --- a/source/extensions/filters/http/lua/config.cc +++ b/source/extensions/filters/http/lua/config.cc @@ -16,7 +16,7 @@ Http::FilterFactoryCb LuaFilterConfig::createFilterFactoryFromProtoTyped( Server::Configuration::FactoryContext& context) { FilterConfigConstSharedPtr filter_config(new FilterConfig{ proto_config, context.threadLocal(), context.clusterManager(), context.api()}); - auto& time_source = context.dispatcher().timeSource(); + auto& time_source = context.mainThreadDispatcher().timeSource(); return [filter_config, &time_source](Http::FilterChainFactoryCallbacks& callbacks) -> void { callbacks.addStreamFilter(std::make_shared(filter_config, time_source)); }; diff --git a/source/extensions/filters/http/lua/lua_filter.cc b/source/extensions/filters/http/lua/lua_filter.cc index 5c78826978676..2549e75dc77d4 100644 --- a/source/extensions/filters/http/lua/lua_filter.cc +++ b/source/extensions/filters/http/lua/lua_filter.cc @@ -700,7 +700,7 @@ FilterConfig::FilterConfig(const envoy::extensions::filters::http::lua::v3::Lua& FilterConfigPerRoute::FilterConfigPerRoute( const envoy::extensions::filters::http::lua::v3::LuaPerRoute& config, Server::Configuration::ServerFactoryContext& context) - : main_thread_dispatcher_(context.dispatcher()), disabled_(config.disabled()), + : main_thread_dispatcher_(context.mainThreadDispatcher()), disabled_(config.disabled()), name_(config.name()) { if (disabled_ || !name_.empty()) { return; diff --git a/source/extensions/filters/http/tap/config.cc b/source/extensions/filters/http/tap/config.cc index ab992a89a40ce..5c573924f768e 100644 --- a/source/extensions/filters/http/tap/config.cc +++ b/source/extensions/filters/http/tap/config.cc @@ -26,9 +26,10 @@ class HttpTapConfigFactoryImpl : public Extensions::Common::Tap::TapConfigFactor Http::FilterFactoryCb TapFilterFactory::createFilterFactoryFromProtoTyped( const envoy::extensions::filters::http::tap::v3::Tap& proto_config, const std::string& stats_prefix, Server::Configuration::FactoryContext& context) { - FilterConfigSharedPtr filter_config(new FilterConfigImpl( - proto_config, stats_prefix, std::make_unique(), context.scope(), - context.admin(), context.singletonManager(), context.threadLocal(), context.dispatcher())); + FilterConfigSharedPtr filter_config( + new FilterConfigImpl(proto_config, stats_prefix, std::make_unique(), + context.scope(), context.admin(), context.singletonManager(), + context.threadLocal(), context.mainThreadDispatcher())); return [filter_config](Http::FilterChainFactoryCallbacks& callbacks) -> void { auto filter = std::make_shared(filter_config); callbacks.addStreamFilter(filter); diff --git a/source/extensions/filters/http/wasm/wasm_filter.cc b/source/extensions/filters/http/wasm/wasm_filter.cc index 4296be89d40b3..75e06e69b735a 100644 --- a/source/extensions/filters/http/wasm/wasm_filter.cc +++ b/source/extensions/filters/http/wasm/wasm_filter.cc @@ -21,8 +21,8 @@ FilterConfig::FilterConfig(const envoy::extensions::filters::http::wasm::v3::Was }; if (!Common::Wasm::createWasm(plugin, context.scope().createScope(""), context.clusterManager(), - context.initManager(), context.dispatcher(), context.api(), - context.lifecycleNotifier(), remote_data_provider_, + context.initManager(), context.mainThreadDispatcher(), + context.api(), context.lifecycleNotifier(), remote_data_provider_, std::move(callback))) { throw Common::Wasm::WasmException( fmt::format("Unable to create Wasm HTTP filter {}", plugin->name_)); diff --git a/source/extensions/filters/network/client_ssl_auth/config.cc b/source/extensions/filters/network/client_ssl_auth/config.cc index f974b275274fa..dcd2db9f47a43 100644 --- a/source/extensions/filters/network/client_ssl_auth/config.cc +++ b/source/extensions/filters/network/client_ssl_auth/config.cc @@ -19,7 +19,7 @@ Network::FilterFactoryCb ClientSslAuthConfigFactory::createFilterFactoryFromProt ASSERT(!proto_config.stat_prefix().empty()); ClientSslAuthConfigSharedPtr filter_config(ClientSslAuthConfig::create( - proto_config, context.threadLocal(), context.clusterManager(), context.dispatcher(), + proto_config, context.threadLocal(), context.clusterManager(), context.mainThreadDispatcher(), context.scope(), context.api().randomGenerator())); return [filter_config](Network::FilterManager& filter_manager) -> void { filter_manager.addReadFilter(std::make_shared(filter_config)); diff --git a/source/extensions/filters/network/dubbo_proxy/config.cc b/source/extensions/filters/network/dubbo_proxy/config.cc index 8bc19cd46663a..ad379489f362f 100644 --- a/source/extensions/filters/network/dubbo_proxy/config.cc +++ b/source/extensions/filters/network/dubbo_proxy/config.cc @@ -22,8 +22,9 @@ Network::FilterFactoryCb DubboProxyFilterConfigFactory::createFilterFactoryFromP std::shared_ptr filter_config(std::make_shared(proto_config, context)); return [filter_config, &context](Network::FilterManager& filter_manager) -> void { - filter_manager.addReadFilter(std::make_shared( - *filter_config, context.api().randomGenerator(), context.dispatcher().timeSource())); + filter_manager.addReadFilter( + std::make_shared(*filter_config, context.api().randomGenerator(), + context.mainThreadDispatcher().timeSource())); }; } diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index 53223b12160c3..42e3da563f829 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -151,8 +151,8 @@ Utility::Singletons Utility::createSingletons(Server::Configuration::FactoryCont std::shared_ptr date_provider = context.singletonManager().getTyped( SINGLETON_MANAGER_REGISTERED_NAME(date_provider), [&context] { - return std::make_shared(context.dispatcher(), - context.threadLocal()); + return std::make_shared( + context.mainThreadDispatcher(), context.threadLocal()); }); Router::RouteConfigProviderManagerSharedPtr route_config_provider_manager = @@ -227,7 +227,7 @@ HttpConnectionManagerFilterConfigFactory::createFilterFactoryFromProtoAndHopByHo auto hcm = std::make_shared( *filter_config, context.drainDecision(), context.api().randomGenerator(), context.httpContext(), context.runtime(), context.localInfo(), context.clusterManager(), - context.overloadManager(), context.dispatcher().timeSource()); + context.overloadManager(), context.mainThreadDispatcher().timeSource()); if (!clear_hop_by_hop_headers) { hcm->setClearHopByHopResponseHeaders(false); } @@ -826,7 +826,7 @@ HttpConnectionManagerFactory::createHttpConnectionManagerFactoryFromProto( auto conn_manager = std::make_unique( *filter_config, context.drainDecision(), context.api().randomGenerator(), context.httpContext(), context.runtime(), context.localInfo(), context.clusterManager(), - context.overloadManager(), context.dispatcher().timeSource()); + context.overloadManager(), context.mainThreadDispatcher().timeSource()); if (!clear_hop_by_hop_headers) { conn_manager->setClearHopByHopResponseHeaders(false); } diff --git a/source/extensions/filters/network/local_ratelimit/config.cc b/source/extensions/filters/network/local_ratelimit/config.cc index e9d2c907bd102..0ae1e20adfb98 100644 --- a/source/extensions/filters/network/local_ratelimit/config.cc +++ b/source/extensions/filters/network/local_ratelimit/config.cc @@ -14,7 +14,7 @@ Network::FilterFactoryCb LocalRateLimitConfigFactory::createFilterFactoryFromPro const envoy::extensions::filters::network::local_ratelimit::v3::LocalRateLimit& proto_config, Server::Configuration::FactoryContext& context) { ConfigSharedPtr filter_config( - new Config(proto_config, context.dispatcher(), context.scope(), context.runtime())); + new Config(proto_config, context.mainThreadDispatcher(), context.scope(), context.runtime())); return [filter_config](Network::FilterManager& filter_manager) -> void { filter_manager.addReadFilter(std::make_shared(filter_config)); }; diff --git a/source/extensions/filters/network/mongo_proxy/config.cc b/source/extensions/filters/network/mongo_proxy/config.cc index 79597c01087ed..4a1fad3d227ea 100644 --- a/source/extensions/filters/network/mongo_proxy/config.cc +++ b/source/extensions/filters/network/mongo_proxy/config.cc @@ -25,7 +25,7 @@ Network::FilterFactoryCb MongoProxyFilterConfigFactory::createFilterFactoryFromP AccessLogSharedPtr access_log; if (!proto_config.access_log().empty()) { access_log = std::make_shared(proto_config.access_log(), context.accessLogManager(), - context.dispatcher().timeSource()); + context.mainThreadDispatcher().timeSource()); } Filters::Common::Fault::FaultDelayConfigSharedPtr fault_config; @@ -45,7 +45,8 @@ Network::FilterFactoryCb MongoProxyFilterConfigFactory::createFilterFactoryFromP stats](Network::FilterManager& filter_manager) -> void { filter_manager.addFilter(std::make_shared( stat_prefix, context.scope(), context.runtime(), access_log, fault_config, - context.drainDecision(), context.dispatcher().timeSource(), emit_dynamic_metadata, stats)); + context.drainDecision(), context.mainThreadDispatcher().timeSource(), emit_dynamic_metadata, + stats)); }; } diff --git a/source/extensions/filters/network/redis_proxy/config.cc b/source/extensions/filters/network/redis_proxy/config.cc index b356418325799..bdef53f8fbcb6 100644 --- a/source/extensions/filters/network/redis_proxy/config.cc +++ b/source/extensions/filters/network/redis_proxy/config.cc @@ -38,7 +38,7 @@ Network::FilterFactoryCb RedisProxyFilterConfigFactory::createFilterFactoryFromP Extensions::Common::Redis::ClusterRefreshManagerSharedPtr refresh_manager = Extensions::Common::Redis::getClusterRefreshManager( - context.singletonManager(), context.dispatcher(), context.clusterManager(), + context.singletonManager(), context.mainThreadDispatcher(), context.clusterManager(), context.timeSource()); ProxyFilterConfigSharedPtr filter_config(std::make_shared( diff --git a/source/extensions/filters/network/thrift_proxy/config.cc b/source/extensions/filters/network/thrift_proxy/config.cc index ae272ed1b480f..180503969176f 100644 --- a/source/extensions/filters/network/thrift_proxy/config.cc +++ b/source/extensions/filters/network/thrift_proxy/config.cc @@ -102,8 +102,9 @@ Network::FilterFactoryCb ThriftProxyFilterConfigFactory::createFilterFactoryFrom std::shared_ptr filter_config(new ConfigImpl(proto_config, context)); return [filter_config, &context](Network::FilterManager& filter_manager) -> void { - filter_manager.addReadFilter(std::make_shared( - *filter_config, context.api().randomGenerator(), context.dispatcher().timeSource())); + filter_manager.addReadFilter( + std::make_shared(*filter_config, context.api().randomGenerator(), + context.mainThreadDispatcher().timeSource())); }; } diff --git a/source/extensions/filters/network/thrift_proxy/router/config.cc b/source/extensions/filters/network/thrift_proxy/router/config.cc index 3e651b2886b7f..a6b28cc58c051 100644 --- a/source/extensions/filters/network/thrift_proxy/router/config.cc +++ b/source/extensions/filters/network/thrift_proxy/router/config.cc @@ -20,7 +20,7 @@ ThriftFilters::FilterFactoryCb RouterFilterConfig::createFilterFactoryFromProtoT auto shadow_writer = std::make_shared(context.clusterManager(), stat_prefix, context.scope(), - context.dispatcher(), context.threadLocal()); + context.mainThreadDispatcher(), context.threadLocal()); return [&context, stat_prefix, shadow_writer](ThriftFilters::FilterChainFactoryCallbacks& callbacks) -> void { diff --git a/source/extensions/filters/network/wasm/wasm_filter.cc b/source/extensions/filters/network/wasm/wasm_filter.cc index 2ee4ea033a36a..d5f1a6a3ba382 100644 --- a/source/extensions/filters/network/wasm/wasm_filter.cc +++ b/source/extensions/filters/network/wasm/wasm_filter.cc @@ -21,8 +21,8 @@ FilterConfig::FilterConfig(const envoy::extensions::filters::network::wasm::v3:: }; if (!Common::Wasm::createWasm(plugin, context.scope().createScope(""), context.clusterManager(), - context.initManager(), context.dispatcher(), context.api(), - context.lifecycleNotifier(), remote_data_provider_, + context.initManager(), context.mainThreadDispatcher(), + context.api(), context.lifecycleNotifier(), remote_data_provider_, std::move(callback))) { throw Common::Wasm::WasmException( fmt::format("Unable to create Wasm network filter {}", plugin->name_)); diff --git a/source/extensions/filters/network/zookeeper_proxy/config.cc b/source/extensions/filters/network/zookeeper_proxy/config.cc index 0a980cf96152d..833eb4563b321 100644 --- a/source/extensions/filters/network/zookeeper_proxy/config.cc +++ b/source/extensions/filters/network/zookeeper_proxy/config.cc @@ -30,7 +30,7 @@ Network::FilterFactoryCb ZooKeeperConfigFactory::createFilterFactoryFromProtoTyp ZooKeeperFilterConfigSharedPtr filter_config( std::make_shared(stat_prefix, max_packet_bytes, context.scope())); - auto& time_source = context.dispatcher().timeSource(); + auto& time_source = context.mainThreadDispatcher().timeSource(); return [filter_config, &time_source](Network::FilterManager& filter_manager) -> void { filter_manager.addFilter(std::make_shared(filter_config, time_source)); diff --git a/source/extensions/health_checkers/redis/config.cc b/source/extensions/health_checkers/redis/config.cc index 880c2b34de770..06f73368ee7eb 100644 --- a/source/extensions/health_checkers/redis/config.cc +++ b/source/extensions/health_checkers/redis/config.cc @@ -18,8 +18,8 @@ Upstream::HealthCheckerSharedPtr RedisHealthCheckerFactory::createCustomHealthCh Server::Configuration::HealthCheckerFactoryContext& context) { return std::make_shared( context.cluster(), config, - getRedisHealthCheckConfig(config, context.messageValidationVisitor()), context.dispatcher(), - context.runtime(), context.eventLogger(), context.api(), + getRedisHealthCheckConfig(config, context.messageValidationVisitor()), + context.mainThreadDispatcher(), context.runtime(), context.eventLogger(), context.api(), NetworkFilters::Common::Redis::Client::ClientFactoryImpl::instance_); }; diff --git a/source/extensions/resource_monitors/injected_resource/injected_resource_monitor.cc b/source/extensions/resource_monitors/injected_resource/injected_resource_monitor.cc index 6aa0aeb76858d..d6797ac85ec2f 100644 --- a/source/extensions/resource_monitors/injected_resource/injected_resource_monitor.cc +++ b/source/extensions/resource_monitors/injected_resource/injected_resource_monitor.cc @@ -16,7 +16,7 @@ InjectedResourceMonitor::InjectedResourceMonitor( config, Server::Configuration::ResourceMonitorFactoryContext& context) : filename_(config.filename()), file_changed_(true), - watcher_(context.dispatcher().createFilesystemWatcher()), api_(context.api()) { + watcher_(context.mainThreadDispatcher().createFilesystemWatcher()), api_(context.api()) { watcher_->addWatch(filename_, Filesystem::Watcher::Events::MovedTo, [this](uint32_t) { onFileChanged(); }); } diff --git a/source/extensions/stat_sinks/wasm/config.cc b/source/extensions/stat_sinks/wasm/config.cc index 96c9814505683..be72fb3d18610 100644 --- a/source/extensions/stat_sinks/wasm/config.cc +++ b/source/extensions/stat_sinks/wasm/config.cc @@ -36,13 +36,13 @@ WasmSinkFactory::createStatsSink(const Protobuf::Message& proto_config, } return; } - wasm_sink->setSingleton( - Common::Wasm::getOrCreateThreadLocalPlugin(base_wasm, plugin, context.dispatcher())); + wasm_sink->setSingleton(Common::Wasm::getOrCreateThreadLocalPlugin( + base_wasm, plugin, context.mainThreadDispatcher())); }; if (!Common::Wasm::createWasm(plugin, context.scope().createScope(""), context.clusterManager(), - context.initManager(), context.dispatcher(), context.api(), - context.lifecycleNotifier(), remote_data_provider_, + context.initManager(), context.mainThreadDispatcher(), + context.api(), context.lifecycleNotifier(), remote_data_provider_, std::move(callback))) { throw Common::Wasm::WasmException( fmt::format("Unable to create Wasm Stat Sink {}", plugin->name_)); diff --git a/source/extensions/transport_sockets/tap/config.cc b/source/extensions/transport_sockets/tap/config.cc index f389c8633c22d..26255d00151d4 100644 --- a/source/extensions/transport_sockets/tap/config.cc +++ b/source/extensions/transport_sockets/tap/config.cc @@ -44,9 +44,10 @@ Network::TransportSocketFactoryPtr UpstreamTapSocketConfigFactory::createTranspo auto inner_transport_factory = inner_config_factory.createTransportSocketFactory(*inner_factory_config, context); return std::make_unique( - outer_config, std::make_unique(context.dispatcher().timeSource()), - context.admin(), context.singletonManager(), context.threadLocal(), context.dispatcher(), - std::move(inner_transport_factory)); + outer_config, + std::make_unique(context.mainThreadDispatcher().timeSource()), + context.admin(), context.singletonManager(), context.threadLocal(), + context.mainThreadDispatcher(), std::move(inner_transport_factory)); } Network::TransportSocketFactoryPtr DownstreamTapSocketConfigFactory::createTransportSocketFactory( @@ -63,9 +64,10 @@ Network::TransportSocketFactoryPtr DownstreamTapSocketConfigFactory::createTrans auto inner_transport_factory = inner_config_factory.createTransportSocketFactory( *inner_factory_config, context, server_names); return std::make_unique( - outer_config, std::make_unique(context.dispatcher().timeSource()), - context.admin(), context.singletonManager(), context.threadLocal(), context.dispatcher(), - std::move(inner_transport_factory)); + outer_config, + std::make_unique(context.mainThreadDispatcher().timeSource()), + context.admin(), context.singletonManager(), context.threadLocal(), + context.mainThreadDispatcher(), std::move(inner_transport_factory)); } ProtobufTypes::MessagePtr TapSocketConfigFactory::createEmptyConfigProto() { diff --git a/source/server/BUILD b/source/server/BUILD index b29bb1a84e333..d78e4c163193b 100644 --- a/source/server/BUILD +++ b/source/server/BUILD @@ -538,6 +538,14 @@ envoy_cc_library( ], ) +envoy_cc_library( + name = "factory_context_base_impl_lib", + hdrs = ["factory_context_base_impl.h"], + deps = [ + "//envoy/server:factory_context_interface", + ], +) + envoy_cc_library( name = "server_lib", srcs = ["server.cc"], diff --git a/source/server/api_listener_impl.h b/source/server/api_listener_impl.h index 6d2b41bcbd3fc..088ec965f21fc 100644 --- a/source/server/api_listener_impl.h +++ b/source/server/api_listener_impl.h @@ -112,7 +112,7 @@ class ApiListenerImplBase : public ApiListener, bool isHalfCloseEnabled() override { NOT_IMPLEMENTED_GCOVR_EXCL_LINE; } void close(Network::ConnectionCloseType) override {} Event::Dispatcher& dispatcher() override { - return parent_.parent_.factory_context_.dispatcher(); + return parent_.parent_.factory_context_.mainThreadDispatcher(); } uint64_t id() const override { return 12345; } void hashKey(std::vector&) const override {} diff --git a/source/server/config_validation/cluster_manager.cc b/source/server/config_validation/cluster_manager.cc index 16ab99e868fc0..742fb4bb3b5ed 100644 --- a/source/server/config_validation/cluster_manager.cc +++ b/source/server/config_validation/cluster_manager.cc @@ -11,8 +11,9 @@ namespace Upstream { ClusterManagerPtr ValidationClusterManagerFactory::clusterManagerFromProto( const envoy::config::bootstrap::v3::Bootstrap& bootstrap) { return std::make_unique( - bootstrap, *this, stats_, tls_, runtime_, local_info_, log_manager_, main_thread_dispatcher_, - admin_, validation_context_, api_, http_context_, grpc_context_, router_context_); + bootstrap, *this, stats_, tls_, context_.runtime(), local_info_, log_manager_, + context_.mainThreadDispatcher(), admin_, validation_context_, context_.api(), http_context_, + grpc_context_, router_context_); } CdsApiPtr ValidationClusterManagerFactory::createCds( diff --git a/source/server/factory_context_base_impl.h b/source/server/factory_context_base_impl.h new file mode 100644 index 0000000000000..4b56a110ccf21 --- /dev/null +++ b/source/server/factory_context_base_impl.h @@ -0,0 +1,49 @@ +#pragma once + +#include "envoy/server/factory_context.h" + +namespace Envoy { +namespace Server { + +class FactoryContextBaseImpl : public Configuration::FactoryContextBase { +public: + FactoryContextBaseImpl(const Server::Options& options, Event::Dispatcher& main_thread_dispatcher, + Api::Api& api, const LocalInfo::LocalInfo& local_info, + Server::Admin& admin, Runtime::Loader& runtime, + Singleton::Manager& singleton_manager, + ProtobufMessage::ValidationVisitor& validation_visitor, + Stats::Store& scope, ThreadLocal::Instance& local) + : options_(options), main_thread_dispatcher_(main_thread_dispatcher), api_(api), + local_info_(local_info), admin_(admin), runtime_(runtime), + singleton_manager_(singleton_manager), validation_visitor_(validation_visitor), + scope_(scope), thread_local_(local) {} + + // FactoryContextBase + const Options& options() override { return options_; }; + Event::Dispatcher& mainThreadDispatcher() override { return main_thread_dispatcher_; }; + Api::Api& api() override { return api_; }; + const LocalInfo::LocalInfo& localInfo() const override { return local_info_; }; + Server::Admin& admin() override { return admin_; }; + Envoy::Runtime::Loader& runtime() override { return runtime_; }; + Singleton::Manager& singletonManager() override { return singleton_manager_; }; + ProtobufMessage::ValidationVisitor& messageValidationVisitor() override { + return validation_visitor_; + }; + Stats::Scope& scope() override { return scope_; }; + ThreadLocal::SlotAllocator& threadLocal() override { return thread_local_; }; + +private: + const Server::Options& options_; + Event::Dispatcher& main_thread_dispatcher_; + Api::Api& api_; + const LocalInfo::LocalInfo& local_info_; + Server::Admin& admin_; + Runtime::Loader& runtime_; + Singleton::Manager& singleton_manager_; + ProtobufMessage::ValidationVisitor& validation_visitor_; + Stats::Store& scope_; + ThreadLocal::Instance& thread_local_; +}; + +} // namespace Server +} // namespace Envoy diff --git a/source/server/filter_chain_manager_impl.cc b/source/server/filter_chain_manager_impl.cc index f1a74a70e78cd..f99ed1f1858c0 100644 --- a/source/server/filter_chain_manager_impl.cc +++ b/source/server/filter_chain_manager_impl.cc @@ -69,8 +69,8 @@ Upstream::ClusterManager& PerFilterChainFactoryContextImpl::clusterManager() { return parent_context_.clusterManager(); } -Event::Dispatcher& PerFilterChainFactoryContextImpl::dispatcher() { - return parent_context_.dispatcher(); +Event::Dispatcher& PerFilterChainFactoryContextImpl::mainThreadDispatcher() { + return parent_context_.mainThreadDispatcher(); } const Server::Options& PerFilterChainFactoryContextImpl::options() { @@ -755,7 +755,7 @@ AccessLog::AccessLogManager& FactoryContextImpl::accessLogManager() { return server_.accessLogManager(); } Upstream::ClusterManager& FactoryContextImpl::clusterManager() { return server_.clusterManager(); } -Event::Dispatcher& FactoryContextImpl::dispatcher() { return server_.dispatcher(); } +Event::Dispatcher& FactoryContextImpl::mainThreadDispatcher() { return server_.dispatcher(); } const Server::Options& FactoryContextImpl::options() { return server_.options(); } Grpc::Context& FactoryContextImpl::grpcContext() { return server_.grpcContext(); } Router::Context& FactoryContextImpl::routerContext() { return server_.routerContext(); } diff --git a/source/server/filter_chain_manager_impl.h b/source/server/filter_chain_manager_impl.h index 8218e89777127..af3be80f7752f 100644 --- a/source/server/filter_chain_manager_impl.h +++ b/source/server/filter_chain_manager_impl.h @@ -55,7 +55,7 @@ class PerFilterChainFactoryContextImpl : public Configuration::FilterChainFactor // Configuration::FactoryContext AccessLog::AccessLogManager& accessLogManager() override; Upstream::ClusterManager& clusterManager() override; - Event::Dispatcher& dispatcher() override; + Event::Dispatcher& mainThreadDispatcher() override; const Server::Options& options() override; Network::DrainDecision& drainDecision() override; Grpc::Context& grpcContext() override; @@ -141,7 +141,7 @@ class FactoryContextImpl : public Configuration::FactoryContext { // Configuration::FactoryContext AccessLog::AccessLogManager& accessLogManager() override; Upstream::ClusterManager& clusterManager() override; - Event::Dispatcher& dispatcher() override; + Event::Dispatcher& mainThreadDispatcher() override; const Server::Options& options() override; Grpc::Context& grpcContext() override; Router::Context& routerContext() override; diff --git a/source/server/listener_impl.cc b/source/server/listener_impl.cc index c6a666477ce35..df53a49ec6535 100644 --- a/source/server/listener_impl.cc +++ b/source/server/listener_impl.cc @@ -223,7 +223,9 @@ AccessLog::AccessLogManager& ListenerFactoryContextBaseImpl::accessLogManager() Upstream::ClusterManager& ListenerFactoryContextBaseImpl::clusterManager() { return server_.clusterManager(); } -Event::Dispatcher& ListenerFactoryContextBaseImpl::dispatcher() { return server_.dispatcher(); } +Event::Dispatcher& ListenerFactoryContextBaseImpl::mainThreadDispatcher() { + return server_.dispatcher(); +} const Server::Options& ListenerFactoryContextBaseImpl::options() { return server_.options(); } Grpc::Context& ListenerFactoryContextBaseImpl::grpcContext() { return server_.grpcContext(); } bool ListenerFactoryContextBaseImpl::healthCheckFailed() { return server_.healthCheckFailed(); } @@ -631,8 +633,8 @@ AccessLog::AccessLogManager& PerListenerFactoryContextImpl::accessLogManager() { Upstream::ClusterManager& PerListenerFactoryContextImpl::clusterManager() { return listener_factory_context_base_->clusterManager(); } -Event::Dispatcher& PerListenerFactoryContextImpl::dispatcher() { - return listener_factory_context_base_->dispatcher(); +Event::Dispatcher& PerListenerFactoryContextImpl::mainThreadDispatcher() { + return listener_factory_context_base_->mainThreadDispatcher(); } const Server::Options& PerListenerFactoryContextImpl::options() { return listener_factory_context_base_->options(); diff --git a/source/server/listener_impl.h b/source/server/listener_impl.h index 0114ff9c9e33e..f621731d7d632 100644 --- a/source/server/listener_impl.h +++ b/source/server/listener_impl.h @@ -104,7 +104,7 @@ class ListenerFactoryContextBaseImpl final : public Configuration::FactoryContex Server::DrainManagerPtr drain_manager); AccessLog::AccessLogManager& accessLogManager() override; Upstream::ClusterManager& clusterManager() override; - Event::Dispatcher& dispatcher() override; + Event::Dispatcher& mainThreadDispatcher() override; const Server::Options& options() override; Network::DrainDecision& drainDecision() override; Grpc::Context& grpcContext() override; @@ -177,7 +177,7 @@ class PerListenerFactoryContextImpl : public Configuration::ListenerFactoryConte // FactoryContext AccessLog::AccessLogManager& accessLogManager() override; Upstream::ClusterManager& clusterManager() override; - Event::Dispatcher& dispatcher() override; + Event::Dispatcher& mainThreadDispatcher() override; const Options& options() override; Network::DrainDecision& drainDecision() override; Grpc::Context& grpcContext() override; diff --git a/source/server/resource_monitor_config_impl.h b/source/server/resource_monitor_config_impl.h index 03ef1c0170941..5bfc8d521e69f 100644 --- a/source/server/resource_monitor_config_impl.h +++ b/source/server/resource_monitor_config_impl.h @@ -14,7 +14,7 @@ class ResourceMonitorFactoryContextImpl : public ResourceMonitorFactoryContext { : dispatcher_(dispatcher), options_(options), api_(api), validation_visitor_(validation_visitor) {} - Event::Dispatcher& dispatcher() override { return dispatcher_; } + Event::Dispatcher& mainThreadDispatcher() override { return dispatcher_; } const Server::Options& options() override { return options_; } diff --git a/source/server/server.h b/source/server/server.h index 9234f6c2ae7b7..d855b5ae46ecd 100644 --- a/source/server/server.h +++ b/source/server/server.h @@ -174,7 +174,7 @@ class ServerFactoryContextImpl : public Configuration::ServerFactoryContext, // Configuration::ServerFactoryContext Upstream::ClusterManager& clusterManager() override { return server_.clusterManager(); } - Event::Dispatcher& dispatcher() override { return server_.dispatcher(); } + Event::Dispatcher& mainThreadDispatcher() override { return server_.dispatcher(); } const Server::Options& options() override { return server_.options(); } const LocalInfo::LocalInfo& localInfo() const override { return server_.localInfo(); } ProtobufMessage::ValidationContext& messageValidationContext() override { diff --git a/source/server/transport_socket_config_impl.h b/source/server/transport_socket_config_impl.h index 600c2e9386826..7a94bd110cecf 100644 --- a/source/server/transport_socket_config_impl.h +++ b/source/server/transport_socket_config_impl.h @@ -40,7 +40,7 @@ class TransportSocketFactoryContextImpl : public TransportSocketFactoryContext { } Upstream::ClusterManager& clusterManager() override { return cluster_manager_; } const LocalInfo::LocalInfo& localInfo() const override { return local_info_; } - Event::Dispatcher& dispatcher() override { return dispatcher_; } + Event::Dispatcher& mainThreadDispatcher() override { return dispatcher_; } Stats::Store& stats() override { return stats_; } Init::Manager& initManager() override { ASSERT(init_manager_ != nullptr); diff --git a/test/common/secret/secret_manager_impl_test.cc b/test/common/secret/secret_manager_impl_test.cc index 15fc8fa59421b..a73f143ba8613 100644 --- a/test/common/secret/secret_manager_impl_test.cc +++ b/test/common/secret/secret_manager_impl_test.cc @@ -279,7 +279,7 @@ TEST_F(SecretManagerImplTest, DeduplicateDynamicTlsCertificateSecretProvider) { })); EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info)); envoy::config::core::v3::ConfigSource config_source; @@ -362,7 +362,7 @@ TEST_F(SecretManagerImplTest, SdsDynamicSecretUpdateSuccess) { })); EXPECT_CALL(secret_context, stats()).WillOnce(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(*dispatcher_)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(*dispatcher_)); EXPECT_CALL(secret_context, localInfo()).WillOnce(ReturnRef(local_info)); EXPECT_CALL(secret_context, api()).WillRepeatedly(ReturnRef(*api_)); @@ -408,7 +408,7 @@ TEST_F(SecretManagerImplTest, SdsDynamicGenericSecret) { Init::TargetHandlePtr init_target_handle; NiceMock init_watcher; - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(*dispatcher_)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(*dispatcher_)); EXPECT_CALL(secret_context, messageValidationVisitor()).WillOnce(ReturnRef(validation_visitor)); EXPECT_CALL(secret_context, stats()).WillOnce(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); @@ -461,7 +461,7 @@ TEST_F(SecretManagerImplTest, ConfigDumpHandler) { })); EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info)); auto secret_provider = @@ -731,7 +731,7 @@ TEST_F(SecretManagerImplTest, ConfigDumpHandlerWarmingSecrets) { })); EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info)); auto secret_provider = @@ -879,7 +879,7 @@ TEST_F(SecretManagerImplTest, ConfigDumpHandlerStaticSecrets) { })); EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info)); const std::string tls_certificate = @@ -956,7 +956,7 @@ TEST_F(SecretManagerImplTest, ConfigDumpHandlerStaticValidationContext) { })); EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info)); const std::string validation_context = @@ -1004,7 +1004,7 @@ TEST_F(SecretManagerImplTest, ConfigDumpHandlerStaticSessionTicketsContext) { })); EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info)); const std::string stek_context = @@ -1085,7 +1085,7 @@ TEST_F(SecretManagerImplTest, SdsDynamicSecretPrivateKeyProviderUpdateSuccess) { })); EXPECT_CALL(secret_context, stats()).WillOnce(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(*dispatcher_)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(*dispatcher_)); EXPECT_CALL(secret_context, localInfo()).WillOnce(ReturnRef(local_info)); EXPECT_CALL(secret_context, api()).WillRepeatedly(ReturnRef(*api_)); diff --git a/test/extensions/filters/http/jwt_authn/filter_config_test.cc b/test/extensions/filters/http/jwt_authn/filter_config_test.cc index c651c932e6db6..a3c8343fc686c 100644 --- a/test/extensions/filters/http/jwt_authn/filter_config_test.cc +++ b/test/extensions/filters/http/jwt_authn/filter_config_test.cc @@ -175,7 +175,8 @@ TEST(HttpJwtAuthnFilterConfigTest, VerifyTLSLifetime) { // The threadLocal, dispatcher and api that are used by the filter config, actually belong to // the server factory context that who's lifetime is longer. We simulate that by returning // their instances from outside the scope. - ON_CALL(context, dispatcher()).WillByDefault(ReturnRef(server_context.dispatcher())); + ON_CALL(context, mainThreadDispatcher()) + .WillByDefault(ReturnRef(server_context.mainThreadDispatcher())); ON_CALL(context, api()).WillByDefault(ReturnRef(server_context.api())); ON_CALL(context, threadLocal()).WillByDefault(ReturnRef(server_context.threadLocal())); diff --git a/test/extensions/filters/http/oauth2/filter_test.cc b/test/extensions/filters/http/oauth2/filter_test.cc index d232adb224d24..dc4f4402cd79d 100644 --- a/test/extensions/filters/http/oauth2/filter_test.cc +++ b/test/extensions/filters/http/oauth2/filter_test.cc @@ -170,7 +170,7 @@ TEST_F(OAuth2Test, SdsDynamicGenericSecret) { NiceMock dispatcher; EXPECT_CALL(secret_context, localInfo()).WillRepeatedly(ReturnRef(local_info)); EXPECT_CALL(secret_context, api()).WillRepeatedly(ReturnRef(*api)); - EXPECT_CALL(secret_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(secret_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(secret_context, stats()).WillRepeatedly(ReturnRef(stats)); EXPECT_CALL(secret_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); EXPECT_CALL(init_manager, add(_)) diff --git a/test/extensions/filters/http/wasm/config_test.cc b/test/extensions/filters/http/wasm/config_test.cc index 52d3a737c98ff..8e3305fc51033 100644 --- a/test/extensions/filters/http/wasm/config_test.cc +++ b/test/extensions/filters/http/wasm/config_test.cc @@ -38,7 +38,7 @@ class WasmFilterConfigTest : public Event::TestUsingSimulatedTime, ON_CALL(context_, listenerMetadata()).WillByDefault(ReturnRef(listener_metadata_)); EXPECT_CALL(context_, initManager()).WillRepeatedly(ReturnRef(init_manager_)); ON_CALL(context_, clusterManager()).WillByDefault(ReturnRef(cluster_manager_)); - ON_CALL(context_, dispatcher()).WillByDefault(ReturnRef(dispatcher_)); + ON_CALL(context_, mainThreadDispatcher()).WillByDefault(ReturnRef(dispatcher_)); } void SetUp() override { Envoy::Extensions::Common::Wasm::clearCodeCacheForTesting(); } diff --git a/test/extensions/filters/network/common/fuzz/uber_readfilter.cc b/test/extensions/filters/network/common/fuzz/uber_readfilter.cc index ca021727c2d17..cb906f81c2680 100644 --- a/test/extensions/filters/network/common/fuzz/uber_readfilter.cc +++ b/test/extensions/filters/network/common/fuzz/uber_readfilter.cc @@ -127,7 +127,7 @@ void UberFilterFuzzer::fuzz( case test::extensions::filters::network::Action::kAdvanceTime: { time_source_.advanceTimeAndRun( std::chrono::milliseconds(action.advance_time().milliseconds()), - factory_context_.dispatcher(), Event::Dispatcher::RunType::NonBlock); + factory_context_.mainThreadDispatcher(), Event::Dispatcher::RunType::NonBlock); break; } default: { diff --git a/test/extensions/filters/network/common/fuzz/uber_writefilter.cc b/test/extensions/filters/network/common/fuzz/uber_writefilter.cc index 6772fe995e22c..941d5b121acc9 100644 --- a/test/extensions/filters/network/common/fuzz/uber_writefilter.cc +++ b/test/extensions/filters/network/common/fuzz/uber_writefilter.cc @@ -103,7 +103,7 @@ void UberWriteFilterFuzzer::fuzz( case test::extensions::filters::network::WriteAction::kAdvanceTime: { time_source_.advanceTimeAndRun( std::chrono::milliseconds(action.advance_time().milliseconds()), - factory_context_.dispatcher(), Event::Dispatcher::RunType::NonBlock); + factory_context_.mainThreadDispatcher(), Event::Dispatcher::RunType::NonBlock); break; } default: { diff --git a/test/extensions/filters/network/common/fuzz/utils/fakes.h b/test/extensions/filters/network/common/fuzz/utils/fakes.h index e9edf5bb5bba0..44193a979a9e0 100644 --- a/test/extensions/filters/network/common/fuzz/utils/fakes.h +++ b/test/extensions/filters/network/common/fuzz/utils/fakes.h @@ -13,7 +13,7 @@ class FakeFactoryContext : public MockFactoryContext { } AccessLog::AccessLogManager& accessLogManager() override { return access_log_manager_; } Upstream::ClusterManager& clusterManager() override { return cluster_manager_; } - Event::Dispatcher& dispatcher() override { return *dispatcher_; } + Event::Dispatcher& mainThreadDispatcher() override { return *dispatcher_; } const Network::DrainDecision& drainDecision() override { return drain_manager_; } Init::Manager& initManager() override { return init_manager_; } ServerLifecycleNotifier& lifecycleNotifier() override { return lifecycle_notifier_; } diff --git a/test/extensions/filters/network/dubbo_proxy/conn_manager_test.cc b/test/extensions/filters/network/dubbo_proxy/conn_manager_test.cc index 56c60e93bb3f9..8cdbe6162927f 100644 --- a/test/extensions/filters/network/dubbo_proxy/conn_manager_test.cc +++ b/test/extensions/filters/network/dubbo_proxy/conn_manager_test.cc @@ -120,7 +120,7 @@ class ConnectionManagerTest : public testing::Test { filter_callbacks_.connection_.dispatcher_.clearDeferredDeleteList(); } - TimeSource& timeSystem() { return factory_context_.dispatcher().timeSource(); } + TimeSource& timeSystem() { return factory_context_.mainThreadDispatcher().timeSource(); } void initializeFilter() { initializeFilter(""); } diff --git a/test/extensions/filters/network/http_connection_manager/config_test_base.h b/test/extensions/filters/network/http_connection_manager/config_test_base.h index 995cb9842e146..9241da2bff892 100644 --- a/test/extensions/filters/network/http_connection_manager/config_test_base.h +++ b/test/extensions/filters/network/http_connection_manager/config_test_base.h @@ -34,7 +34,7 @@ parseHttpConnectionManagerFromYaml(const std::string& yaml) { class HttpConnectionManagerConfigTest : public testing::Test { public: NiceMock context_; - Http::SlowDateProviderImpl date_provider_{context_.dispatcher().timeSource()}; + Http::SlowDateProviderImpl date_provider_{context_.mainThreadDispatcher().timeSource()}; NiceMock route_config_provider_manager_; NiceMock scoped_routes_config_provider_manager_; NiceMock http_tracer_manager_; diff --git a/test/extensions/filters/network/wasm/config_test.cc b/test/extensions/filters/network/wasm/config_test.cc index e77a38efad53e..9673c4d598a39 100644 --- a/test/extensions/filters/network/wasm/config_test.cc +++ b/test/extensions/filters/network/wasm/config_test.cc @@ -30,7 +30,7 @@ class WasmNetworkFilterConfigTest : public testing::TestWithParam { ON_CALL(context_, listenerMetadata()).WillByDefault(ReturnRef(listener_metadata_)); ON_CALL(context_, initManager()).WillByDefault(ReturnRef(init_manager_)); ON_CALL(context_, clusterManager()).WillByDefault(ReturnRef(cluster_manager_)); - ON_CALL(context_, dispatcher()).WillByDefault(ReturnRef(dispatcher_)); + ON_CALL(context_, mainThreadDispatcher()).WillByDefault(ReturnRef(dispatcher_)); } void SetUp() override { Envoy::Extensions::Common::Wasm::clearCodeCacheForTesting(); } diff --git a/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc b/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc index 400f97a4d11b2..5d05210ad4f11 100644 --- a/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc +++ b/test/extensions/resource_monitors/injected_resource/injected_resource_monitor_test.cc @@ -26,7 +26,7 @@ class TestableInjectedResourceMonitor : public InjectedResourceMonitor { const envoy::extensions::resource_monitors::injected_resource::v3::InjectedResourceConfig& config, Server::Configuration::ResourceMonitorFactoryContext& context) - : InjectedResourceMonitor(config, context), dispatcher_(context.dispatcher()) {} + : InjectedResourceMonitor(config, context), dispatcher_(context.mainThreadDispatcher()) {} protected: void onFileChanged() override { diff --git a/test/extensions/transport_sockets/tls/context_impl_test.cc b/test/extensions/transport_sockets/tls/context_impl_test.cc index 5e2de45ee3819..0967e77d25b05 100644 --- a/test/extensions/transport_sockets/tls/context_impl_test.cc +++ b/test/extensions/transport_sockets/tls/context_impl_test.cc @@ -813,7 +813,7 @@ TEST_F(SslServerContextImplTicketTest, TicketKeySdsNotReady) { NiceMock cluster_manager; NiceMock init_manager; EXPECT_CALL(factory_context_, localInfo()).WillOnce(ReturnRef(local_info)); - EXPECT_CALL(factory_context_, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(factory_context_, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); // EXPECT_CALL(factory_context_, random()).WillOnce(ReturnRef(random)); EXPECT_CALL(factory_context_, stats()).WillOnce(ReturnRef(stats)); EXPECT_CALL(factory_context_, clusterManager()).WillOnce(ReturnRef(cluster_manager)); @@ -1219,7 +1219,7 @@ TEST_F(ClientContextConfigImplTest, SecretNotReady) { EXPECT_CALL(factory_context_, localInfo()).WillOnce(ReturnRef(local_info)); EXPECT_CALL(factory_context_, stats()).WillOnce(ReturnRef(stats)); EXPECT_CALL(factory_context_, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(factory_context_, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(factory_context_, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); auto sds_secret_configs = tls_context.mutable_common_tls_context()->mutable_tls_certificate_sds_secret_configs()->Add(); sds_secret_configs->set_name("abc.com"); @@ -1251,7 +1251,7 @@ TEST_F(ClientContextConfigImplTest, ValidationContextNotReady) { EXPECT_CALL(factory_context_, localInfo()).WillOnce(ReturnRef(local_info)); EXPECT_CALL(factory_context_, stats()).WillOnce(ReturnRef(stats)); EXPECT_CALL(factory_context_, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(factory_context_, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(factory_context_, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); auto sds_secret_configs = tls_context.mutable_common_tls_context()->mutable_validation_context_sds_secret_config(); sds_secret_configs->set_name("abc.com"); @@ -1557,7 +1557,7 @@ TEST_F(ServerContextConfigImplTest, SecretNotReady) { EXPECT_CALL(factory_context_, localInfo()).WillOnce(ReturnRef(local_info)); EXPECT_CALL(factory_context_, stats()).WillOnce(ReturnRef(stats)); EXPECT_CALL(factory_context_, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(factory_context_, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(factory_context_, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); auto sds_secret_configs = tls_context.mutable_common_tls_context()->mutable_tls_certificate_sds_secret_configs()->Add(); sds_secret_configs->set_name("abc.com"); @@ -1589,7 +1589,7 @@ TEST_F(ServerContextConfigImplTest, ValidationContextNotReady) { EXPECT_CALL(factory_context_, localInfo()).WillOnce(ReturnRef(local_info)); EXPECT_CALL(factory_context_, stats()).WillOnce(ReturnRef(stats)); EXPECT_CALL(factory_context_, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(factory_context_, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(factory_context_, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); auto sds_secret_configs = tls_context.mutable_common_tls_context()->mutable_validation_context_sds_secret_config(); sds_secret_configs->set_name("abc.com"); diff --git a/test/extensions/transport_sockets/tls/ssl_socket_test.cc b/test/extensions/transport_sockets/tls/ssl_socket_test.cc index db8cd6b6cec52..24b2e1422c7ee 100644 --- a/test/extensions/transport_sockets/tls/ssl_socket_test.cc +++ b/test/extensions/transport_sockets/tls/ssl_socket_test.cc @@ -4720,7 +4720,7 @@ TEST_P(SslSocketTest, DownstreamNotReadySslSocket) { testing::NiceMock factory_context; NiceMock init_manager; NiceMock dispatcher; - EXPECT_CALL(factory_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(factory_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); EXPECT_CALL(factory_context, localInfo()).WillOnce(ReturnRef(local_info)); EXPECT_CALL(factory_context, stats()).WillOnce(ReturnRef(stats_store)); EXPECT_CALL(factory_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); @@ -4760,7 +4760,7 @@ TEST_P(SslSocketTest, UpstreamNotReadySslSocket) { EXPECT_CALL(factory_context, localInfo()).WillOnce(ReturnRef(local_info)); EXPECT_CALL(factory_context, stats()).WillOnce(ReturnRef(stats_store)); EXPECT_CALL(factory_context, initManager()).WillRepeatedly(ReturnRef(init_manager)); - EXPECT_CALL(factory_context, dispatcher()).WillRepeatedly(ReturnRef(dispatcher)); + EXPECT_CALL(factory_context, mainThreadDispatcher()).WillRepeatedly(ReturnRef(dispatcher)); envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context; auto sds_secret_configs = diff --git a/test/integration/clusters/custom_static_cluster.h b/test/integration/clusters/custom_static_cluster.h index 5570338047634..6daeb9220eda4 100644 --- a/test/integration/clusters/custom_static_cluster.h +++ b/test/integration/clusters/custom_static_cluster.h @@ -29,7 +29,7 @@ class CustomStaticCluster : public Upstream::ClusterImplBase { Stats::ScopePtr&& stats_scope, bool added_via_api, uint32_t priority, std::string address, uint32_t port) : ClusterImplBase(cluster, runtime, factory_context, std::move(stats_scope), added_via_api, - factory_context.dispatcher().timeSource()), + factory_context.mainThreadDispatcher().timeSource()), priority_(priority), address_(std::move(address)), port_(port), host_(makeHost()) {} InitializePhase initializePhase() const override { return InitializePhase::Primary; } diff --git a/test/integration/fake_resource_monitor.cc b/test/integration/fake_resource_monitor.cc index 9dc8e4b0060ab..85a11084f6e14 100644 --- a/test/integration/fake_resource_monitor.cc +++ b/test/integration/fake_resource_monitor.cc @@ -16,7 +16,7 @@ void FakeResourceMonitorFactory::onMonitorDestroyed(FakeResourceMonitor* monitor } Server::ResourceMonitorPtr FakeResourceMonitorFactory::createResourceMonitor( const Protobuf::Message&, Server::Configuration::ResourceMonitorFactoryContext& context) { - auto monitor = std::make_unique(context.dispatcher(), *this); + auto monitor = std::make_unique(context.mainThreadDispatcher(), *this); monitor_ = monitor.get(); return monitor; } diff --git a/test/mocks/server/factory_context.cc b/test/mocks/server/factory_context.cc index c8a3e082414cf..5e59724def957 100644 --- a/test/mocks/server/factory_context.cc +++ b/test/mocks/server/factory_context.cc @@ -20,7 +20,7 @@ MockFactoryContext::MockFactoryContext() ON_CALL(*this, getServerFactoryContext()).WillByDefault(ReturnRef(server_factory_context_)); ON_CALL(*this, accessLogManager()).WillByDefault(ReturnRef(access_log_manager_)); ON_CALL(*this, clusterManager()).WillByDefault(ReturnRef(cluster_manager_)); - ON_CALL(*this, dispatcher()).WillByDefault(ReturnRef(dispatcher_)); + ON_CALL(*this, mainThreadDispatcher()).WillByDefault(ReturnRef(dispatcher_)); ON_CALL(*this, drainDecision()).WillByDefault(ReturnRef(drain_manager_)); ON_CALL(*this, getTransportSocketFactoryContext()) .WillByDefault(ReturnRef(transport_socket_factory_context_)); diff --git a/test/mocks/server/factory_context.h b/test/mocks/server/factory_context.h index ec7e6f8659ef0..0de704bbee3c7 100644 --- a/test/mocks/server/factory_context.h +++ b/test/mocks/server/factory_context.h @@ -25,7 +25,7 @@ class MockFactoryContext : public virtual FactoryContext { MOCK_METHOD(TransportSocketFactoryContext&, getTransportSocketFactoryContext, (), (const)); MOCK_METHOD(AccessLog::AccessLogManager&, accessLogManager, ()); MOCK_METHOD(Upstream::ClusterManager&, clusterManager, ()); - MOCK_METHOD(Event::Dispatcher&, dispatcher, ()); + MOCK_METHOD(Event::Dispatcher&, mainThreadDispatcher, ()); MOCK_METHOD(const Server::Options&, options, ()); MOCK_METHOD(const Network::DrainDecision&, drainDecision, ()); MOCK_METHOD(bool, healthCheckFailed, ()); diff --git a/test/mocks/server/health_checker_factory_context.cc b/test/mocks/server/health_checker_factory_context.cc index f6a17d962e2ac..93d5611cdd0f7 100644 --- a/test/mocks/server/health_checker_factory_context.cc +++ b/test/mocks/server/health_checker_factory_context.cc @@ -14,7 +14,7 @@ using ::testing::ReturnRef; MockHealthCheckerFactoryContext::MockHealthCheckerFactoryContext() { event_logger_ = new testing::NiceMock(); ON_CALL(*this, cluster()).WillByDefault(ReturnRef(cluster_)); - ON_CALL(*this, dispatcher()).WillByDefault(ReturnRef(dispatcher_)); + ON_CALL(*this, mainThreadDispatcher()).WillByDefault(ReturnRef(dispatcher_)); ON_CALL(*this, random()).WillByDefault(ReturnRef(random_)); ON_CALL(*this, runtime()).WillByDefault(ReturnRef(runtime_)); ON_CALL(*this, eventLogger_()).WillByDefault(Return(event_logger_)); diff --git a/test/mocks/server/health_checker_factory_context.h b/test/mocks/server/health_checker_factory_context.h index 35b94285948fa..15ac903feff66 100644 --- a/test/mocks/server/health_checker_factory_context.h +++ b/test/mocks/server/health_checker_factory_context.h @@ -23,7 +23,7 @@ class MockHealthCheckerFactoryContext : public virtual HealthCheckerFactoryConte ~MockHealthCheckerFactoryContext() override; MOCK_METHOD(Upstream::Cluster&, cluster, ()); - MOCK_METHOD(Event::Dispatcher&, dispatcher, ()); + MOCK_METHOD(Event::Dispatcher&, mainThreadDispatcher, ()); MOCK_METHOD(Envoy::Random::RandomGenerator&, random, ()); MOCK_METHOD(Envoy::Runtime::Loader&, runtime, ()); MOCK_METHOD(Upstream::HealthCheckEventLogger*, eventLogger_, ()); diff --git a/test/mocks/server/instance.cc b/test/mocks/server/instance.cc index f19f81dc4afcd..3ea0f9ea53ad4 100644 --- a/test/mocks/server/instance.cc +++ b/test/mocks/server/instance.cc @@ -61,7 +61,7 @@ MockServerFactoryContext::MockServerFactoryContext() : singleton_manager_(new Singleton::ManagerImpl(Thread::threadFactoryForTest())), grpc_context_(scope_.symbolTable()), router_context_(scope_.symbolTable()) { ON_CALL(*this, clusterManager()).WillByDefault(ReturnRef(cluster_manager_)); - ON_CALL(*this, dispatcher()).WillByDefault(ReturnRef(dispatcher_)); + ON_CALL(*this, mainThreadDispatcher()).WillByDefault(ReturnRef(dispatcher_)); ON_CALL(*this, drainDecision()).WillByDefault(ReturnRef(drain_manager_)); ON_CALL(*this, localInfo()).WillByDefault(ReturnRef(local_info_)); ON_CALL(*this, runtime()).WillByDefault(ReturnRef(runtime_loader_)); diff --git a/test/mocks/server/instance.h b/test/mocks/server/instance.h index 455e82eebfec5..51858c0ba7f17 100644 --- a/test/mocks/server/instance.h +++ b/test/mocks/server/instance.h @@ -149,7 +149,7 @@ class MockServerFactoryContext : public virtual ServerFactoryContext { ~MockServerFactoryContext() override; MOCK_METHOD(Upstream::ClusterManager&, clusterManager, ()); - MOCK_METHOD(Event::Dispatcher&, dispatcher, ()); + MOCK_METHOD(Event::Dispatcher&, mainThreadDispatcher, ()); MOCK_METHOD(const Server::Options&, options, ()); MOCK_METHOD(const Network::DrainDecision&, drainDecision, ()); MOCK_METHOD(const LocalInfo::LocalInfo&, localInfo, (), (const)); diff --git a/test/mocks/server/listener_factory_context.cc b/test/mocks/server/listener_factory_context.cc index bf2cc8992247c..fd8c0e047d130 100644 --- a/test/mocks/server/listener_factory_context.cc +++ b/test/mocks/server/listener_factory_context.cc @@ -20,7 +20,7 @@ MockListenerFactoryContext::MockListenerFactoryContext() ON_CALL(*this, getServerFactoryContext()).WillByDefault(ReturnRef(server_factory_context_)); ON_CALL(*this, accessLogManager()).WillByDefault(ReturnRef(access_log_manager_)); ON_CALL(*this, clusterManager()).WillByDefault(ReturnRef(cluster_manager_)); - ON_CALL(*this, dispatcher()).WillByDefault(ReturnRef(dispatcher_)); + ON_CALL(*this, mainThreadDispatcher()).WillByDefault(ReturnRef(dispatcher_)); ON_CALL(*this, drainDecision()).WillByDefault(ReturnRef(drain_manager_)); ON_CALL(*this, initManager()).WillByDefault(ReturnRef(init_manager_)); ON_CALL(*this, lifecycleNotifier()).WillByDefault(ReturnRef(lifecycle_notifier_)); diff --git a/test/mocks/server/listener_factory_context.h b/test/mocks/server/listener_factory_context.h index 095aad5931dcb..c78138e477def 100644 --- a/test/mocks/server/listener_factory_context.h +++ b/test/mocks/server/listener_factory_context.h @@ -26,7 +26,7 @@ class MockListenerFactoryContext : public ListenerFactoryContext { MOCK_METHOD(TransportSocketFactoryContext&, getTransportSocketFactoryContext, (), (const)); MOCK_METHOD(AccessLog::AccessLogManager&, accessLogManager, ()); MOCK_METHOD(Upstream::ClusterManager&, clusterManager, ()); - MOCK_METHOD(Event::Dispatcher&, dispatcher, ()); + MOCK_METHOD(Event::Dispatcher&, mainThreadDispatcher, ()); MOCK_METHOD(const Server::Options&, options, ()); MOCK_METHOD(const Network::DrainDecision&, drainDecision, ()); MOCK_METHOD(bool, healthCheckFailed, ()); diff --git a/test/mocks/server/transport_socket_factory_context.h b/test/mocks/server/transport_socket_factory_context.h index ee98720c8d428..fe31909626259 100644 --- a/test/mocks/server/transport_socket_factory_context.h +++ b/test/mocks/server/transport_socket_factory_context.h @@ -27,7 +27,7 @@ class MockTransportSocketFactoryContext : public TransportSocketFactoryContext { MOCK_METHOD(Stats::Scope&, scope, ()); MOCK_METHOD(Upstream::ClusterManager&, clusterManager, ()); MOCK_METHOD(const LocalInfo::LocalInfo&, localInfo, (), (const)); - MOCK_METHOD(Event::Dispatcher&, dispatcher, ()); + MOCK_METHOD(Event::Dispatcher&, mainThreadDispatcher, ()); MOCK_METHOD(const Server::Options&, options, ()); MOCK_METHOD(Envoy::Random::RandomGenerator&, random, ()); MOCK_METHOD(Stats::Store&, stats, ()); diff --git a/test/server/overload_manager_impl_test.cc b/test/server/overload_manager_impl_test.cc index 60b2214487c8e..0886e0181d5ff 100644 --- a/test/server/overload_manager_impl_test.cc +++ b/test/server/overload_manager_impl_test.cc @@ -99,7 +99,7 @@ class FakeResourceMonitorFactory : public Server::Configuration::ResourceMonitor Server::ResourceMonitorPtr createResourceMonitor(const Protobuf::Message&, Server::Configuration::ResourceMonitorFactoryContext& context) override { - auto monitor = std::make_unique(context.dispatcher()); + auto monitor = std::make_unique(context.mainThreadDispatcher()); monitor_ = monitor.get(); return monitor; } diff --git a/test/tools/router_check/router.cc b/test/tools/router_check/router.cc index eb5f1853e3736..3dedd6238e57a 100644 --- a/test/tools/router_check/router.cc +++ b/test/tools/router_check/router.cc @@ -243,9 +243,9 @@ bool RouterCheckTool::compareEntries(const std::string& expected_routes) { headers_finalized_ = false; auto connection_info_provider = std::make_shared( nullptr, Network::Utility::getCanonicalIpv4LoopbackAddress()); - Envoy::StreamInfo::StreamInfoImpl stream_info(Envoy::Http::Protocol::Http11, - factory_context_->dispatcher().timeSource(), - connection_info_provider); + Envoy::StreamInfo::StreamInfoImpl stream_info( + Envoy::Http::Protocol::Http11, factory_context_->mainThreadDispatcher().timeSource(), + connection_info_provider); ToolConfig tool_config = ToolConfig::create(check_config); tool_config.route_ = config_->route(*tool_config.request_headers_, stream_info, tool_config.random_value_);