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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <string>
       4             : 
       5             : #include "envoy/config/core/v3/health_check.pb.h"
       6             : #include "envoy/config/typed_config.h"
       7             : #include "envoy/event/dispatcher.h"
       8             : #include "envoy/init/manager.h"
       9             : #include "envoy/local_info/local_info.h"
      10             : #include "envoy/network/transport_socket.h"
      11             : #include "envoy/secret/secret_manager.h"
      12             : #include "envoy/server/factory_context.h"
      13             : #include "envoy/singleton/manager.h"
      14             : #include "envoy/ssl/context_manager.h"
      15             : #include "envoy/stats/scope.h"
      16             : #include "envoy/thread_local/thread_local.h"
      17             : #include "envoy/upstream/cluster_manager.h"
      18             : 
      19             : #include "source/common/protobuf/protobuf.h"
      20             : 
      21             : namespace Envoy {
      22             : namespace Server {
      23             : namespace Configuration {
      24             : 
      25             : /**
      26             :  * Context passed to transport socket factory to access server resources.
      27             :  */
      28             : class TransportSocketFactoryContext {
      29             : public:
      30         871 :   virtual ~TransportSocketFactoryContext() = default;
      31             : 
      32             :   /**
      33             :    * @return ServerFactoryContext& the server factory context.
      34             :    */
      35             :   virtual ServerFactoryContext& serverFactoryContext() PURE;
      36             : 
      37             :   /**
      38             :    * @return Upstream::ClusterManager& singleton for use by the entire server.
      39             :    * TODO(wbpcode): clusterManager() of ServerFactoryContext still be invalid when loading
      40             :    * static cluster. So we need to provide an cluster manager reference here.
      41             :    * This could be removed after https://github.com/envoyproxy/envoy/issues/26653 is resolved.
      42             :    */
      43             :   virtual Upstream::ClusterManager& clusterManager() PURE;
      44             : 
      45             :   /**
      46             :    * @return ProtobufMessage::ValidationVisitor& validation visitor for cluster configuration
      47             :    * messages.
      48             :    */
      49             :   virtual ProtobufMessage::ValidationVisitor& messageValidationVisitor() PURE;
      50             : 
      51             :   /**
      52             :    * @return Ssl::ContextManager& the SSL context manager.
      53             :    */
      54             :   virtual Ssl::ContextManager& sslContextManager() PURE;
      55             : 
      56             :   /**
      57             :    * @return Stats::Scope& the transport socket's stats scope.
      58             :    */
      59             :   virtual Stats::Scope& statsScope() PURE;
      60             : 
      61             :   /**
      62             :    * Return the instance of secret manager.
      63             :    */
      64             :   virtual Secret::SecretManager& secretManager() PURE;
      65             : 
      66             :   /**
      67             :    * @return the init manager of the particular context.
      68             :    */
      69             :   virtual Init::Manager& initManager() PURE;
      70             : };
      71             : 
      72             : using TransportSocketFactoryContextPtr = std::unique_ptr<TransportSocketFactoryContext>;
      73             : 
      74             : class TransportSocketConfigFactory : public Config::TypedFactory {
      75             : public:
      76           0 :   ~TransportSocketConfigFactory() override = default;
      77             : };
      78             : 
      79             : /**
      80             :  * Implemented by each transport socket used for upstream connections. Registered via class
      81             :  * RegisterFactory.
      82             :  */
      83             : class UpstreamTransportSocketConfigFactory : public virtual TransportSocketConfigFactory {
      84             : public:
      85             :   /**
      86             :    * Create a particular transport socket factory implementation.
      87             :    * @param config const Protobuf::Message& supplies the config message for the transport socket
      88             :    *        implementation.
      89             :    * @param context TransportSocketFactoryContext& supplies the transport socket's context.
      90             :    * @return Network::UpstreamTransportSocketFactoryPtr the transport socket factory instance. The
      91             :    * returned TransportSocketFactoryPtr should not be nullptr.
      92             :    *
      93             :    * @throw EnvoyException if the implementation is unable to produce a factory with the provided
      94             :    *        parameters.
      95             :    */
      96             :   virtual Network::UpstreamTransportSocketFactoryPtr
      97             :   createTransportSocketFactory(const Protobuf::Message& config,
      98             :                                TransportSocketFactoryContext& context) PURE;
      99             : 
     100         152 :   std::string category() const override { return "envoy.transport_sockets.upstream"; }
     101             : };
     102             : 
     103             : /**
     104             :  * Implemented by each transport socket used for downstream connections. Registered via class
     105             :  * RegisterFactory.
     106             :  */
     107             : class DownstreamTransportSocketConfigFactory : public virtual TransportSocketConfigFactory {
     108             : public:
     109             :   /**
     110             :    * Create a particular downstream transport socket factory implementation.
     111             :    * @param server_names const std::vector<std::string>& the names of the server. This parameter is
     112             :    *        currently used by SNI implementation to know the expected server names.
     113             :    * @param config const Protobuf::Message& supplies the config message for the transport socket
     114             :    *        implementation.
     115             :    * @param context TransportSocketFactoryContext& supplies the transport socket's context.
     116             :    * @return Network::DownstreamTransportSocketFactoryPtr the transport socket factory instance. The
     117             :    * returned TransportSocketFactoryPtr should not be nullptr.
     118             :    *
     119             :    * @throw EnvoyException if the implementation is unable to produce a factory with the provided
     120             :    *        parameters.
     121             :    */
     122             :   virtual Network::DownstreamTransportSocketFactoryPtr
     123             :   createTransportSocketFactory(const Protobuf::Message& config,
     124             :                                TransportSocketFactoryContext& context,
     125             :                                const std::vector<std::string>& server_names) PURE;
     126             : 
     127          62 :   std::string category() const override { return "envoy.transport_sockets.downstream"; }
     128             : };
     129             : 
     130             : } // namespace Configuration
     131             : } // namespace Server
     132             : } // namespace Envoy

Generated by: LCOV version 1.15