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

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <chrono>
       4             : #include <cstdint>
       5             : #include <string>
       6             : 
       7             : #include "envoy/common/exception.h"
       8             : #include "envoy/config/bootstrap/v3/bootstrap.pb.h"
       9             : #include "envoy/registry/registry.h"
      10             : #include "envoy/server/options.h"
      11             : 
      12             : #include "source/common/common/logger.h"
      13             : #include "source/common/config/well_known_names.h"
      14             : #include "source/server/options_impl_base.h"
      15             : 
      16             : #include "spdlog/spdlog.h"
      17             : 
      18             : namespace Envoy {
      19             : 
      20             : /**
      21             :  * Implementation of Server::Options which can parse from the command line.
      22             :  */
      23             : class OptionsImpl : public OptionsImplBase {
      24             : public:
      25             :   /**
      26             :    * Parameters are hot_restart_enabled
      27             :    */
      28             :   using HotRestartVersionCb = std::function<std::string(bool)>;
      29             : 
      30             :   /**
      31             :    * @throw NoServingException if Envoy has already done everything specified by the args (e.g.
      32             :    *        print the hot restart version) and it's time to exit without serving HTTP traffic. The
      33             :    *        caller should exit(0) after any necessary cleanup.
      34             :    * @throw MalformedArgvException if something is wrong with the arguments (invalid flag or flag
      35             :    *        value). The caller should call exit(1) after any necessary cleanup.
      36             :    */
      37             :   OptionsImpl(int argc, const char* const* argv, const HotRestartVersionCb& hot_restart_version_cb,
      38             :               spdlog::level::level_enum default_log_level);
      39             : 
      40             :   /**
      41             :    * @throw NoServingException if Envoy has already done everything specified by the args (e.g.
      42             :    *        print the hot restart version) and it's time to exit without serving HTTP traffic. The
      43             :    *        caller should exit(0) after any necessary cleanup.
      44             :    * @throw MalformedArgvException if something is wrong with the arguments (invalid flag or flag
      45             :    *        value). The caller should call exit(1) after any necessary cleanup.
      46             :    */
      47             :   OptionsImpl(std::vector<std::string> args, const HotRestartVersionCb& hot_restart_version_cb,
      48             :               spdlog::level::level_enum default_log_level);
      49             : 
      50             :   // Default constructor; creates "reasonable" defaults, but desired values should be set
      51             :   // explicitly.
      52             :   OptionsImpl(const std::string& service_cluster, const std::string& service_node,
      53             :               const std::string& service_zone, spdlog::level::level_enum log_level);
      54             : 
      55             :   Server::CommandLineOptionsPtr toCommandLineOptions() const override;
      56             :   void parseComponentLogLevels(const std::string& component_log_levels);
      57             :   static void logError(const std::string& error);
      58             :   static std::string allowedLogLevels();
      59             : };
      60             : 
      61             : /**
      62             :  * Thrown when an OptionsImpl was not constructed because all of Envoy's work is done (for example,
      63             :  * it was started with --help and it's already printed a help message) so all that's left to do is
      64             :  * exit successfully.
      65             :  */
      66             : class NoServingException : public EnvoyException {
      67             : public:
      68           0 :   NoServingException(const std::string& what) : EnvoyException(what) {}
      69             : };
      70             : 
      71             : /**
      72             :  * Thrown when an OptionsImpl was not constructed because the argv was invalid.
      73             :  */
      74             : class MalformedArgvException : public EnvoyException {
      75             : public:
      76           0 :   MalformedArgvException(const std::string& what) : EnvoyException(what) {}
      77             : };
      78             : 
      79             : } // namespace Envoy

Generated by: LCOV version 1.15