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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/api/api.h"
       4             : #include "envoy/common/pure.h"
       5             : #include "envoy/config/typed_config.h"
       6             : #include "envoy/event/dispatcher.h"
       7             : #include "envoy/protobuf/message_validator.h"
       8             : #include "envoy/server/options.h"
       9             : #include "envoy/server/proactive_resource_monitor.h"
      10             : #include "envoy/server/resource_monitor.h"
      11             : 
      12             : #include "source/common/protobuf/protobuf.h"
      13             : 
      14             : namespace Envoy {
      15             : namespace Server {
      16             : namespace Configuration {
      17             : 
      18             : class ResourceMonitorFactoryContext {
      19             : public:
      20         248 :   virtual ~ResourceMonitorFactoryContext() = default;
      21             : 
      22             :   /**
      23             :    * @return Event::Dispatcher& the main thread's dispatcher. This dispatcher should be used
      24             :    *         for all singleton processing.
      25             :    */
      26             :   virtual Event::Dispatcher& mainThreadDispatcher() PURE;
      27             : 
      28             :   /**
      29             :    * @return Server::Options& the command-line options that Envoy was started with.
      30             :    */
      31             :   virtual const Options& options() PURE;
      32             : 
      33             :   /**
      34             :    * @return reference to the Api object
      35             :    */
      36             :   virtual Api::Api& api() PURE;
      37             : 
      38             :   /**
      39             :    * @return ProtobufMessage::ValidationVisitor& validation visitor for filter configuration
      40             :    *         messages.
      41             :    */
      42             :   virtual ProtobufMessage::ValidationVisitor& messageValidationVisitor() PURE;
      43             : };
      44             : 
      45             : /**
      46             :  * Implemented by each resource monitor and registered via Registry::registerFactory()
      47             :  * or the convenience class RegistryFactory.
      48             :  */
      49             : class ResourceMonitorFactory : public Config::TypedFactory {
      50             : public:
      51           0 :   ~ResourceMonitorFactory() override = default;
      52             : 
      53             :   /**
      54             :    * Create a particular resource monitor implementation.
      55             :    * @param config const ProtoBuf::Message& supplies the config for the resource monitor
      56             :    *        implementation.
      57             :    * @param context ResourceMonitorFactoryContext& supplies the resource monitor's context.
      58             :    * @return ResourceMonitorPtr the resource monitor instance. Should not be nullptr.
      59             :    * @throw EnvoyException if the implementation is unable to produce an instance with
      60             :    *        the provided parameters.
      61             :    */
      62             :   virtual ResourceMonitorPtr createResourceMonitor(const Protobuf::Message& config,
      63             :                                                    ResourceMonitorFactoryContext& context) PURE;
      64             : 
      65           4 :   std::string category() const override { return "envoy.resource_monitors"; }
      66             : };
      67             : 
      68             : class ProactiveResourceMonitorFactory : public Config::TypedFactory {
      69             : public:
      70           0 :   ~ProactiveResourceMonitorFactory() override = default;
      71             : 
      72             :   /**
      73             :    * Create a particular proactive resource monitor implementation.
      74             :    * @param config const ProtoBuf::Message& supplies the config for the proactive resource monitor
      75             :    *        implementation.
      76             :    * @param context ResourceMonitorFactoryContext& supplies the resource monitor's context.
      77             :    * @return ProactiveResourceMonitorPtr the resource monitor instance. Should not be nullptr.
      78             :    * @throw EnvoyException if the implementation is unable to produce an instance with
      79             :    *        the provided parameters.
      80             :    */
      81             :   virtual ProactiveResourceMonitorPtr
      82             :   createProactiveResourceMonitor(const Protobuf::Message& config,
      83             :                                  ResourceMonitorFactoryContext& context) PURE;
      84             : 
      85           4 :   std::string category() const override { return "envoy.resource_monitors"; }
      86             : };
      87             : 
      88             : } // namespace Configuration
      89             : } // namespace Server
      90             : } // namespace Envoy

Generated by: LCOV version 1.15