LCOV - code coverage report
Current view: top level - envoy/server - instance.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 1 1 100.0 %
Date: 2024-01-05 06:35:25 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <chrono>
       4             : #include <cstdint>
       5             : #include <memory>
       6             : #include <string>
       7             : 
       8             : #include "envoy/access_log/access_log.h"
       9             : #include "envoy/api/api.h"
      10             : #include "envoy/common/mutex_tracer.h"
      11             : #include "envoy/common/random_generator.h"
      12             : #include "envoy/config/trace/v3/http_tracer.pb.h"
      13             : #include "envoy/event/timer.h"
      14             : #include "envoy/grpc/context.h"
      15             : #include "envoy/http/context.h"
      16             : #include "envoy/init/manager.h"
      17             : #include "envoy/local_info/local_info.h"
      18             : #include "envoy/network/listen_socket.h"
      19             : #include "envoy/runtime/runtime.h"
      20             : #include "envoy/secret/secret_manager.h"
      21             : #include "envoy/server/admin.h"
      22             : #include "envoy/server/configuration.h"
      23             : #include "envoy/server/drain_manager.h"
      24             : #include "envoy/server/hot_restart.h"
      25             : #include "envoy/server/lifecycle_notifier.h"
      26             : #include "envoy/server/listener_manager.h"
      27             : #include "envoy/server/options.h"
      28             : #include "envoy/server/overload/overload_manager.h"
      29             : #include "envoy/ssl/context_manager.h"
      30             : #include "envoy/thread_local/thread_local.h"
      31             : #include "envoy/tracing/tracer.h"
      32             : #include "envoy/upstream/cluster_manager.h"
      33             : 
      34             : namespace Envoy {
      35             : 
      36             : namespace Stats {
      37             : class SinkPredicates;
      38             : }
      39             : 
      40             : namespace Server {
      41             : 
      42             : /**
      43             :  * An instance of the running server.
      44             :  */
      45             : class Instance {
      46             : public:
      47         455 :   virtual ~Instance() = default;
      48             : 
      49             :   /**
      50             :    * Runs the server.
      51             :    */
      52             :   virtual void run() PURE;
      53             : 
      54             :   /**
      55             :    * @return OptRef<Admin> the global HTTP admin endpoint for the server.
      56             :    */
      57             :   virtual OptRef<Admin> admin() PURE;
      58             : 
      59             :   /**
      60             :    * @return Api::Api& the API used by the server.
      61             :    */
      62             :   virtual Api::Api& api() PURE;
      63             : 
      64             :   /**
      65             :    * @return Upstream::ClusterManager& singleton for use by the entire server.
      66             :    */
      67             :   virtual Upstream::ClusterManager& clusterManager() PURE;
      68             : 
      69             :   /**
      70             :    * @return const Upstream::ClusterManager& singleton for use by the entire server.
      71             :    */
      72             :   virtual const Upstream::ClusterManager& clusterManager() const PURE;
      73             : 
      74             :   /**
      75             :    * @return Ssl::ContextManager& singleton for use by the entire server.
      76             :    */
      77             :   virtual Ssl::ContextManager& sslContextManager() PURE;
      78             : 
      79             :   /**
      80             :    * @return Event::Dispatcher& the main thread's dispatcher. This dispatcher should be used
      81             :    *         for all singleton processing.
      82             :    */
      83             :   virtual Event::Dispatcher& dispatcher() PURE;
      84             : 
      85             :   /**
      86             :    * @return Network::DnsResolverSharedPtr the singleton DNS resolver for the server.
      87             :    */
      88             :   virtual Network::DnsResolverSharedPtr dnsResolver() PURE;
      89             : 
      90             :   /**
      91             :    * Close the server's listening sockets and begin draining the listeners.
      92             :    * @param options - if provided, options are passed through to shutdownListener.
      93             :    */
      94             :   virtual void
      95             :   drainListeners(OptRef<const Network::ExtraShutdownListenerOptions> options = absl::nullopt) PURE;
      96             : 
      97             :   /**
      98             :    * @return DrainManager& singleton for use by the entire server.
      99             :    */
     100             :   virtual DrainManager& drainManager() PURE;
     101             : 
     102             :   /**
     103             :    * @return AccessLogManager for use by the entire server.
     104             :    */
     105             :   virtual AccessLog::AccessLogManager& accessLogManager() PURE;
     106             : 
     107             :   /**
     108             :    * Toggle whether the server fails or passes external healthchecks.
     109             :    */
     110             :   virtual void failHealthcheck(bool fail) PURE;
     111             : 
     112             :   /**
     113             :    * @return whether external healthchecks are currently failed or not.
     114             :    */
     115             :   virtual bool healthCheckFailed() PURE;
     116             : 
     117             :   /**
     118             :    * @return the server's hot restarter.
     119             :    */
     120             :   virtual HotRestart& hotRestart() PURE;
     121             : 
     122             :   /**
     123             :    * @return the server's init manager. This can be used for extensions that need to initialize
     124             :    *         after cluster manager init but before the server starts listening. All extensions
     125             :    *         should register themselves during configuration load. initialize() will be called on
     126             :    *         each registered target after cluster manager init but before the server starts
     127             :    *         listening. Once all targets have initialized and invoked their callbacks, the server
     128             :    *         will start listening.
     129             :    */
     130             :   virtual Init::Manager& initManager() PURE;
     131             : 
     132             :   /**
     133             :    * @return the server's listener manager.
     134             :    */
     135             :   virtual ListenerManager& listenerManager() PURE;
     136             : 
     137             :   /**
     138             :    * @return the server's global mutex tracer, if it was instantiated. Nullptr otherwise.
     139             :    */
     140             :   virtual Envoy::MutexTracer* mutexTracer() PURE;
     141             : 
     142             :   /**
     143             :    * @return the server's overload manager.
     144             :    */
     145             :   virtual OverloadManager& overloadManager() PURE;
     146             : 
     147             :   /**
     148             :    * @return the server's secret manager
     149             :    */
     150             :   virtual Secret::SecretManager& secretManager() PURE;
     151             : 
     152             :   /**
     153             :    * @return the server's CLI options.
     154             :    */
     155             :   virtual const Options& options() PURE;
     156             : 
     157             :   /**
     158             :    * @return Runtime::Loader& the singleton runtime loader for the server.
     159             :    */
     160             :   virtual Runtime::Loader& runtime() PURE;
     161             : 
     162             :   /**
     163             :    * @return ServerLifecycleNotifier& the singleton lifecycle notifier for the server.
     164             :    */
     165             :   virtual ServerLifecycleNotifier& lifecycleNotifier() PURE;
     166             : 
     167             :   /**
     168             :    * Shutdown the server gracefully.
     169             :    */
     170             :   virtual void shutdown() PURE;
     171             : 
     172             :   /**
     173             :    * @return whether the shutdown method has been called.
     174             :    */
     175             :   virtual bool isShutdown() PURE;
     176             : 
     177             :   /**
     178             :    * Shutdown the server's admin processing. This includes the admin API, stat flushing, etc.
     179             :    */
     180             :   virtual void shutdownAdmin() PURE;
     181             : 
     182             :   /**
     183             :    * @return Singleton::Manager& the server-wide singleton manager.
     184             :    */
     185             :   virtual Singleton::Manager& singletonManager() PURE;
     186             : 
     187             :   /**
     188             :    * @return the time that the server started during the current hot restart epoch.
     189             :    */
     190             :   virtual time_t startTimeCurrentEpoch() PURE;
     191             : 
     192             :   /**
     193             :    * @return the time that the server started the first hot restart epoch.
     194             :    */
     195             :   virtual time_t startTimeFirstEpoch() PURE;
     196             : 
     197             :   /**
     198             :    * @return the server-wide stats store.
     199             :    */
     200             :   virtual Stats::Store& stats() PURE;
     201             : 
     202             :   /**
     203             :    * @return the server-wide grpc context.
     204             :    */
     205             :   virtual Grpc::Context& grpcContext() PURE;
     206             : 
     207             :   /**
     208             :    * @return the server-wide http context.
     209             :    */
     210             :   virtual Http::Context& httpContext() PURE;
     211             : 
     212             :   /**
     213             :    * @return the server-wide router context.
     214             :    */
     215             :   virtual Router::Context& routerContext() PURE;
     216             : 
     217             :   /**
     218             :    * @return the server-wide process context.
     219             :    */
     220             :   virtual ProcessContextOptRef processContext() PURE;
     221             : 
     222             :   /**
     223             :    * @return ThreadLocal::Instance& the thread local storage engine for the server. This is used to
     224             :    *         allow runtime lockless updates to configuration, etc. across multiple threads.
     225             :    */
     226             :   virtual ThreadLocal::Instance& threadLocal() PURE;
     227             : 
     228             :   /**
     229             :    * @return information about the local environment the server is running in.
     230             :    */
     231             :   virtual LocalInfo::LocalInfo& localInfo() const PURE;
     232             : 
     233             :   /**
     234             :    * @return the time source used for the server.
     235             :    */
     236             :   virtual TimeSource& timeSource() PURE;
     237             : 
     238             :   /**
     239             :    * Flush the stats sinks outside of a flushing interval.
     240             :    * Note: stats flushing may not be synchronous.
     241             :    * Therefore, this function may return prior to flushing taking place.
     242             :    */
     243             :   virtual void flushStats() PURE;
     244             : 
     245             :   /**
     246             :    * @return ProtobufMessage::ValidationContext& validation context for configuration
     247             :    *         messages.
     248             :    */
     249             :   virtual ProtobufMessage::ValidationContext& messageValidationContext() PURE;
     250             : 
     251             :   /**
     252             :    * @return const StatsConfig& the configuration of server stats.
     253             :    */
     254             :   virtual Configuration::StatsConfig& statsConfig() PURE;
     255             : 
     256             :   /**
     257             :    * @return envoy::config::bootstrap::v3::Bootstrap& the servers bootstrap configuration.
     258             :    */
     259             :   virtual envoy::config::bootstrap::v3::Bootstrap& bootstrap() PURE;
     260             : 
     261             :   /**
     262             :    * @return Configuration::ServerFactoryContext& factory context for filters.
     263             :    */
     264             :   virtual Configuration::ServerFactoryContext& serverFactoryContext() PURE;
     265             : 
     266             :   /**
     267             :    * @return Configuration::TransportSocketFactoryContext& factory context for transport sockets.
     268             :    */
     269             :   virtual Configuration::TransportSocketFactoryContext& transportSocketFactoryContext() PURE;
     270             : 
     271             :   /**
     272             :    * Set the default server-wide tracer provider configuration that will be used as a fallback
     273             :    * if an "envoy.filters.network.http_connection_manager" filter that has tracing enabled doesn't
     274             :    * define a tracer provider in-place.
     275             :    *
     276             :    * Once deprecation window for the tracer provider configuration in the bootstrap config is over,
     277             :    * this method will no longer be necessary.
     278             :    */
     279             :   virtual void
     280             :   setDefaultTracingConfig(const envoy::config::trace::v3::Tracing& tracing_config) PURE;
     281             : 
     282             :   /**
     283             :    * Return the default for whether reuse_port is enabled or not. This was added as part of
     284             :    * fixing https://github.com/envoyproxy/envoy/issues/15794. It is required to know what the
     285             :    * default was of parent processes during hot restart was, because otherwise switching the
     286             :    * default on the fly will break existing deployments.
     287             :    * TODO(mattklein123): This can be removed when version 1.20.0 is no longer supported.
     288             :    */
     289             :   virtual bool enableReusePortDefault() PURE;
     290             : 
     291             :   /**
     292             :    * Set predicates for filtering stats to be flushed to sinks.
     293             :    */
     294             :   virtual void
     295             :   setSinkPredicates(std::unique_ptr<Envoy::Stats::SinkPredicates>&& sink_predicates) PURE;
     296             : };
     297             : 
     298             : } // namespace Server
     299             : } // namespace Envoy

Generated by: LCOV version 1.15