LCOV - code coverage report
Current view: top level - source/extensions/common/tap - extension_config_base.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 3 3 100.0 %
Date: 2024-01-05 06:35:25 Functions: 1 2 50.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/config/tap/v3/common.pb.h"
       4             : #include "envoy/extensions/common/tap/v3/common.pb.h"
       5             : #include "envoy/thread_local/thread_local.h"
       6             : 
       7             : #include "source/extensions/common/tap/admin.h"
       8             : #include "source/extensions/common/tap/tap.h"
       9             : 
      10             : namespace Envoy {
      11             : namespace Extensions {
      12             : namespace Common {
      13             : namespace Tap {
      14             : 
      15             : /**
      16             :  * Base class for tap extension configuration. Used by all tap extensions.
      17             :  */
      18             : class ExtensionConfigBase : public ExtensionConfig, Logger::Loggable<Logger::Id::tap> {
      19             : public:
      20             :   // Extensions::Common::Tap::ExtensionConfig
      21             :   void clearTapConfig() override;
      22             :   const absl::string_view adminId() override;
      23             :   void newTapConfig(const envoy::config::tap::v3::TapConfig& proto_config,
      24             :                     Sink* admin_streamer) override;
      25             : 
      26             : protected:
      27             :   ExtensionConfigBase(const envoy::extensions::common::tap::v3::CommonExtensionConfig proto_config,
      28             :                       TapConfigFactoryPtr&& config_factory, OptRef<Server::Admin> admin,
      29             :                       Singleton::Manager& singleton_manager, ThreadLocal::SlotAllocator& tls,
      30             :                       Event::Dispatcher& main_thread_dispatcher);
      31             :   ~ExtensionConfigBase() override;
      32             : 
      33             :   // All tap configurations derive from TapConfig for type safety. In order to use a common
      34             :   // extension base class (with TLS logic, etc.) we must dynamic cast to the actual tap
      35             :   // configuration type that the extension expects (and is created by the configuration factory).
      36           2 :   template <class T> std::shared_ptr<T> currentConfigHelper() const {
      37           2 :     return std::dynamic_pointer_cast<T>(tls_slot_->config_);
      38           2 :   }
      39             : 
      40             : private:
      41             :   // Holds the functionality of installing a new tap config. This is the underlying method to the
      42             :   // virtual method newTapConfig.
      43             :   void installNewTap(const envoy::config::tap::v3::TapConfig& proto_config, Sink* admin_streamer);
      44             : 
      45             :   struct TlsFilterConfig : public ThreadLocal::ThreadLocalObject {
      46             :     TapConfigSharedPtr config_;
      47             :   };
      48             : 
      49             :   const envoy::extensions::common::tap::v3::CommonExtensionConfig proto_config_;
      50             :   TapConfigFactoryPtr config_factory_;
      51             :   ThreadLocal::TypedSlot<TlsFilterConfig> tls_slot_;
      52             :   AdminHandlerSharedPtr admin_handler_;
      53             : };
      54             : 
      55             : } // namespace Tap
      56             : } // namespace Common
      57             : } // namespace Extensions
      58             : } // namespace Envoy

Generated by: LCOV version 1.15