-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathoptions_impl.h
192 lines (171 loc) · 9.02 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#pragma once
#include <chrono>
#include <cmath>
#include <cstdint>
#include <string>
#include "nighthawk/client/options.h"
#include "nighthawk/common/exception.h"
#include "external/envoy/source/common/common/logger.h"
#include "external/envoy/source/common/protobuf/protobuf.h"
#include "absl/types/optional.h"
#include "tclap/CmdLine.h"
namespace Nighthawk {
namespace Client {
class OptionsImpl : public Options, public Envoy::Logger::Loggable<Envoy::Logger::Id::main> {
public:
// We cap on negative values. TCLAP accepts negative values which we will get here as very
// large values. We just cap values, hoping we catch accidental wraparound to a reasonable extent.
static constexpr uint32_t largest_acceptable_uint32_option_value = UINT32_MAX - 30000;
// The largest acceptable value for the maxConcurrentStreams() option.
// Source:
// https://github.com/envoyproxy/envoy/blob/70aa8c8f0af949ee1fe965b0a826c9a3e2c634f0/api/envoy/config/core/v3/protocol.proto#L304-L316
static constexpr uint32_t largest_acceptable_concurrent_streams_value = 2147483647;
OptionsImpl(int argc, const char* const* argv);
OptionsImpl(const nighthawk::client::CommandLineOptions& options);
Client::CommandLineOptionsPtr toCommandLineOptions() const override;
uint32_t requestsPerSecond() const override { return requests_per_second_; }
uint32_t connections() const override { return connections_; }
std::chrono::seconds duration() const override { return std::chrono::seconds(duration_); }
std::chrono::seconds timeout() const override { return std::chrono::seconds(timeout_); }
absl::optional<std::string> uri() const override { return uri_; }
Envoy::Http::Protocol protocol() const override;
const absl::optional<envoy::config::core::v3::Http3ProtocolOptions>&
http3ProtocolOptions() const override {
return http3_protocol_options_;
}
std::string concurrency() const override { return concurrency_; }
nighthawk::client::Verbosity::VerbosityOptions verbosity() const override { return verbosity_; };
nighthawk::client::OutputFormat::OutputFormatOptions outputFormat() const override {
return output_format_;
};
bool prefetchConnections() const override { return prefetch_connections_; }
uint32_t burstSize() const override { return burst_size_; }
nighthawk::client::AddressFamily::AddressFamilyOptions addressFamily() const override {
return address_family_;
};
envoy::config::core::v3::RequestMethod requestMethod() const override { return request_method_; };
std::vector<std::string> requestHeaders() const override { return request_headers_; };
uint32_t requestBodySize() const override { return request_body_size_; };
const envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext&
tlsContext() const override {
return tls_context_;
};
const absl::optional<envoy::config::core::v3::BindConfig>& upstreamBindConfig() const override {
return upstream_bind_config_;
}
const absl::optional<envoy::config::core::v3::TransportSocket>& transportSocket() const override {
return transport_socket_;
}
uint32_t maxPendingRequests() const override { return max_pending_requests_; }
uint32_t maxActiveRequests() const override { return max_active_requests_; }
uint32_t maxRequestsPerConnection() const override { return max_requests_per_connection_; }
uint32_t maxConcurrentStreams() const override { return max_concurrent_streams_; }
nighthawk::client::SequencerIdleStrategy::SequencerIdleStrategyOptions
sequencerIdleStrategy() const override {
return sequencer_idle_strategy_;
}
std::string requestSource() const override { return request_source_; }
const absl::optional<envoy::config::core::v3::TypedExtensionConfig>&
requestSourcePluginConfig() const override {
return request_source_plugin_config_;
}
std::string trace() const override { return trace_; }
nighthawk::client::H1ConnectionReuseStrategy::H1ConnectionReuseStrategyOptions
h1ConnectionReuseStrategy() const override {
return experimental_h1_connection_reuse_strategy_;
}
TerminationPredicateMap terminationPredicates() const override { return termination_predicates_; }
TerminationPredicateMap failurePredicates() const override { return failure_predicates_; }
bool noDefaultFailurePredicates() const override { return no_default_failure_predicates_; }
bool openLoop() const override { return open_loop_; }
std::chrono::nanoseconds jitterUniform() const override { return jitter_uniform_; }
std::string nighthawkService() const override { return nighthawk_service_; }
std::vector<std::string> labels() const override { return labels_; };
std::vector<nighthawk::client::MultiTarget::Endpoint> multiTargetEndpoints() const override {
return multi_target_endpoints_;
}
std::string multiTargetPath() const override { return multi_target_path_; }
bool multiTargetUseHttps() const override { return multi_target_use_https_; }
bool simpleWarmup() const override { return simple_warmup_; }
bool noDuration() const override { return no_duration_; }
std::vector<envoy::config::metrics::v3::StatsSink> statsSinks() const override {
return stats_sinks_;
}
uint32_t statsFlushInterval() const override { return stats_flush_interval_; }
Envoy::ProtobufWkt::Duration statsFlushIntervalDuration() const override {
return stats_flush_interval_duration_;
}
std::string responseHeaderWithLatencyInput() const override {
return latency_response_header_name_;
};
absl::optional<Envoy::SystemTime> scheduled_start() const override { return scheduled_start_; }
absl::optional<std::string> executionId() const override { return execution_id_; }
const std::vector<envoy::config::core::v3::TypedExtensionConfig>&
userDefinedOutputPluginConfigs() const override {
return user_defined_output_plugin_configs_;
}
private:
void parsePredicates(const TCLAP::MultiArg<std::string>& arg,
TerminationPredicateMap& predicates);
void setNonTrivialDefaults();
void validate() const;
Client::CommandLineOptionsPtr toCommandLineOptionsInternal() const;
uint32_t requests_per_second_{5};
uint32_t connections_{100};
uint32_t duration_{5};
uint32_t timeout_{30};
absl::optional<std::string> uri_;
bool h2_{false}; // Deprecated.
nighthawk::client::Protocol::ProtocolOptions protocol_{nighthawk::client::Protocol::HTTP1};
absl::optional<envoy::config::core::v3::Http3ProtocolOptions> http3_protocol_options_;
std::string concurrency_;
nighthawk::client::Verbosity::VerbosityOptions verbosity_{nighthawk::client::Verbosity::WARN};
nighthawk::client::OutputFormat::OutputFormatOptions output_format_{
nighthawk::client::OutputFormat::JSON};
bool prefetch_connections_{false};
uint32_t burst_size_{0};
nighthawk::client::AddressFamily::AddressFamilyOptions address_family_{
nighthawk::client::AddressFamily::AUTO};
envoy::config::core::v3::RequestMethod request_method_{
envoy::config::core::v3::RequestMethod::GET};
std::vector<std::string> request_headers_;
uint32_t request_body_size_{0};
envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context_;
absl::optional<envoy::config::core::v3::BindConfig> upstream_bind_config_;
absl::optional<envoy::config::core::v3::TransportSocket> transport_socket_;
absl::optional<envoy::config::core::v3::TypedExtensionConfig> request_source_plugin_config_;
uint32_t max_pending_requests_{0};
// This default is based the minimum recommendation for SETTINGS_MAX_CONCURRENT_STREAMS over at
// https://tools.ietf.org/html/rfc7540#section-6.5.2
uint32_t max_active_requests_{100};
uint32_t max_requests_per_connection_{largest_acceptable_uint32_option_value};
uint32_t max_concurrent_streams_{largest_acceptable_concurrent_streams_value};
nighthawk::client::SequencerIdleStrategy::SequencerIdleStrategyOptions sequencer_idle_strategy_{
nighthawk::client::SequencerIdleStrategy::SPIN};
std::string request_source_;
std::string trace_;
nighthawk::client::H1ConnectionReuseStrategy::H1ConnectionReuseStrategyOptions
experimental_h1_connection_reuse_strategy_{nighthawk::client::H1ConnectionReuseStrategy::MRU};
TerminationPredicateMap termination_predicates_;
TerminationPredicateMap failure_predicates_;
bool no_default_failure_predicates_{false};
bool open_loop_{false};
std::chrono::nanoseconds jitter_uniform_;
std::string nighthawk_service_;
bool h2_use_multiple_connections_{false}; // Deprecated.
std::vector<nighthawk::client::MultiTarget::Endpoint> multi_target_endpoints_;
std::string multi_target_path_;
bool multi_target_use_https_{false};
std::vector<std::string> labels_;
bool simple_warmup_{false};
bool no_duration_{false};
std::vector<envoy::config::metrics::v3::StatsSink> stats_sinks_;
uint32_t stats_flush_interval_{5};
Envoy::ProtobufWkt::Duration stats_flush_interval_duration_;
std::string latency_response_header_name_;
absl::optional<Envoy::SystemTime> scheduled_start_;
absl::optional<std::string> execution_id_;
std::vector<envoy::config::core::v3::TypedExtensionConfig> user_defined_output_plugin_configs_;
};
} // namespace Client
} // namespace Nighthawk