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