1
#pragma once
2

            
3
#include <chrono>
4
#include <cstdint>
5
#include <list>
6
#include <memory>
7
#include <string>
8
#include <vector>
9

            
10
#include "envoy/config/bootstrap/v3/bootstrap.pb.h"
11
#include "envoy/stats/sink.h"
12
#include "envoy/upstream/cluster_manager.h"
13

            
14
#include "absl/types/optional.h"
15

            
16
namespace Envoy {
17
namespace Server {
18
namespace Configuration {
19

            
20
/*
21
 * Watchdog configuration.
22
 */
23
class Watchdog {
24
public:
25
21682
  virtual ~Watchdog() = default;
26

            
27
  /**
28
   * @return std::chrono::milliseconds the time interval after which we count a nonresponsive thread
29
   *         event as a "miss" statistic.
30
   */
31
  virtual std::chrono::milliseconds missTimeout() const PURE;
32

            
33
  /**
34
   * @return std::chrono::milliseconds the time interval after which we count a nonresponsive thread
35
   *         event as a "mega miss" statistic.
36
   */
37
  virtual std::chrono::milliseconds megaMissTimeout() const PURE;
38

            
39
  /**
40
   * @return std::chrono::milliseconds the time interval after which we kill the process due to a
41
   *         single nonresponsive thread.
42
   */
43
  virtual std::chrono::milliseconds killTimeout() const PURE;
44

            
45
  /**
46
   * @return std::chrono::milliseconds the time interval after which we kill the process due to
47
   *         multiple nonresponsive threads.
48
   */
49
  virtual std::chrono::milliseconds multiKillTimeout() const PURE;
50

            
51
  /**
52
   * @return double the percentage of threads that need to meet the MultiKillTimeout before we
53
   *         kill the process. This is used in the calculation below
54
   *         Max(2, ceil(registered_threads * Fraction(MultiKillThreshold)))
55
   *         which computes the number of threads that need to be be nonresponsive
56
   *         for at least MultiKillTimeout before we kill the process.
57
   */
58
  virtual double multiKillThreshold() const PURE;
59

            
60
  /**
61
   * @return Protobuf::RepeatedPtrField<envoy::config::bootstrap::v3::Watchdog::WatchdogAction>
62
   *         the WatchDog Actions that trigger on WatchDog Events.
63
   */
64
  virtual Protobuf::RepeatedPtrField<envoy::config::bootstrap::v3::Watchdog::WatchdogAction>
65
  actions() const PURE;
66
};
67

            
68
class StatsConfig {
69
public:
70
50819
  virtual ~StatsConfig() = default;
71

            
72
  /**
73
   * @return std::list<Stats::SinkPtr>& the list of stats sinks initialized from the configuration.
74
   */
75
  virtual const std::list<Stats::SinkPtr>& sinks() const PURE;
76

            
77
  /**
78
   * @return std::chrono::milliseconds the time interval between flushing to configured stat sinks.
79
   *         The server latches counters.
80
   */
81
  virtual std::chrono::milliseconds flushInterval() const PURE;
82

            
83
  /**
84
   * @return bool indicator to flush stats on-demand via the admin interface instead of on a timer.
85
   */
86
  virtual bool flushOnAdmin() const PURE;
87

            
88
  /**
89
   * @return true if deferred creation of stats is enabled.
90
   */
91
  virtual bool enableDeferredCreationStats() const PURE;
92

            
93
  /**
94
   * @return uint32_t a multiple of the flush interval to perform stats eviction, or 0 if disabled.
95
   */
96
  virtual uint32_t evictOnFlush() const PURE;
97
};
98

            
99
/**
100
 * The main server configuration.
101
 */
102
class Main {
103
public:
104
10873
  virtual ~Main() = default;
105

            
106
  /**
107
   * @return Upstream::ClusterManager* singleton for use by the entire server.
108
   *         This will be nullptr if the cluster manager has not initialized yet.
109
   */
110
  virtual Upstream::ClusterManager* clusterManager() PURE;
111

            
112
  /**
113
   * @return const Upstream::ClusterManager* singleton for use by the entire server.
114
   *         This will be nullptr if the cluster manager has not initialized yet.
115
   */
116
  virtual const Upstream::ClusterManager* clusterManager() const PURE;
117

            
118
  /**
119
   * @return const StatsConfig& the configuration of server stats.
120
   */
121
  virtual StatsConfig& statsConfig() PURE;
122

            
123
  /**
124
   * @return const Watchdog& the configuration of the main thread watchdog.
125
   */
126
  virtual const Watchdog& mainThreadWatchdogConfig() const PURE;
127

            
128
  /**
129
   * @return const Watchdog& the configuration of the worker watchdog.
130
   */
131
  virtual const Watchdog& workerWatchdogConfig() const PURE;
132
};
133

            
134
/**
135
 * Admin configuration.
136
 */
137
class Admin {
138
public:
139
10815
  virtual ~Admin() = default;
140

            
141
  /**
142
   * @return std::list<AccessLog::InstanceSharedPtr> the list of access loggers.
143
   */
144
  virtual AccessLog::InstanceSharedPtrVector accessLogs() const PURE;
145

            
146
  /**
147
   * @return const std::string& profiler output path.
148
   */
149
  virtual const std::string& profilePath() const PURE;
150

            
151
  /**
152
   * @return Network::Address::InstanceConstSharedPtr the server address.
153
   */
154
  virtual Network::Address::InstanceConstSharedPtr address() PURE;
155

            
156
  /**
157
   * @return Network::Address::OptionsSharedPtr the list of listener socket options.
158
   */
159
  virtual Network::Socket::OptionsSharedPtr socketOptions() PURE;
160

            
161
  /**
162
   * @return bool whether the listener should avoid blocking connections based on the globally set
163
   * limit.
164
   */
165
  virtual bool ignoreGlobalConnLimit() const PURE;
166
};
167

            
168
/**
169
 * Initial configuration values that are needed before the main configuration load.
170
 */
171
class Initial {
172
public:
173
10815
  virtual ~Initial() = default;
174

            
175
  /**
176
   * @return Admin& the admin config.
177
   */
178
  virtual Admin& admin() PURE;
179

            
180
  /**
181
   * @return absl::optional<std::string> the path to look for flag files.
182
   */
183
  virtual absl::optional<std::string> flagsPath() const PURE;
184

            
185
  /**
186
   * @return const envoy::config::bootstrap::v2::LayeredRuntime& runtime
187
   *         configuration.
188
   */
189
  virtual const envoy::config::bootstrap::v3::LayeredRuntime& runtime() PURE;
190
};
191

            
192
} // namespace Configuration
193
} // namespace Server
194
} // namespace Envoy