Skip to content

Commit 8ee78db

Browse files
committed
review feedback
Signed-off-by: Otto van der Schaaf <[email protected]>
1 parent 1cd6cd7 commit 8ee78db

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

source/server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ admin:
7777
7878
The [ResponseOptions proto](/api/server/response_options.proto) is shared by
7979
the `Test Server` and `Dynamic Delay` filter extensions. Each filter will
80-
interpret the parts that are relevant to it. This allows specifying a what
80+
interpret the parts that are relevant to it. This allows specifying what
8181
a response should look like in a single message, which can be done at request
8282
time via the optional `x-nighthawk-test-server-config` request-header.
8383

source/server/http_dynamic_delay_filter.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,30 @@ HttpDynamicDelayDecoderFilter::decodeHeaders(Envoy::Http::RequestHeaderMap& head
5555
delay_ms = computeDelayMilliseconds(current_value, concurrency_config.minimal_delay(),
5656
concurrency_config.concurrency_delay_factor());
5757
}
58+
maybeRequestFaultFilterDelay(delay_ms, headers);
59+
return Envoy::Http::FilterHeadersStatus::Continue;
60+
}
61+
62+
void HttpDynamicDelayDecoderFilter::maybeRequestFaultFilterDelay(
63+
const absl::optional<int64_t> delay_ms, Envoy::Http::RequestHeaderMap& headers) {
5864
if (delay_ms.has_value() && delay_ms > 0) {
5965
// Emit header to communicate the delay we desire to the fault filter extension.
6066
const Envoy::Http::LowerCaseString key("x-envoy-fault-delay-request");
6167
headers.setCopy(key, absl::StrCat(*delay_ms));
6268
}
63-
return Envoy::Http::FilterHeadersStatus::Continue;
6469
}
6570

6671
Envoy::Http::FilterDataStatus HttpDynamicDelayDecoderFilter::decodeData(Envoy::Buffer::Instance&,
6772
bool) {
73+
// Minimal implementation that satisfies the contract imposed by Http::StreamDecoderFilter:
74+
// we do nothing, and request the state machine that drives us to continue.
6875
return Envoy::Http::FilterDataStatus::Continue;
6976
}
7077

7178
Envoy::Http::FilterTrailersStatus
7279
HttpDynamicDelayDecoderFilter::decodeTrailers(Envoy::Http::RequestTrailerMap&) {
80+
// Minimal implementation that satisfies the contract imposed by Http::StreamDecoderFilter:
81+
// we do nothing, and request the state machine that drives us to continue.
7382
return Envoy::Http::FilterTrailersStatus::Continue;
7483
}
7584

source/server/http_dynamic_delay_filter.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ class HttpDynamicDelayDecoderFilter : public Envoy::Http::StreamDecoderFilter {
8686
1e6);
8787
}
8888

89+
/**
90+
* Communicate to the fault filter, which should be running after this filter, that a delay should
91+
* be inserted. The request is only made when the passed delay is set to a value > 0.
92+
*
93+
* @param delay_ms The delay that should be propagated, if any. When not set or <= 0, the call
94+
* will be a no-op.
95+
* @param request_headers The request headers that will be modified to instruct the faul filter.
96+
*/
97+
static void maybeRequestFaultFilterDelay(const absl::optional<int64_t> delay_ms,
98+
Envoy::Http::RequestHeaderMap& request_headers);
99+
89100
private:
90101
const HttpDynamicDelayDecoderFilterConfigSharedPtr config_;
91102
Envoy::Http::StreamDecoderFilterCallbacks* decoder_callbacks_;

source/server/http_dynamic_delay_filter_config.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Nighthawk {
1313
namespace Server {
1414
namespace Configuration {
15+
namespace {
1516

1617
class HttpDynamicDelayDecoderFilterConfigFactory
1718
: public Envoy::Server::Configuration::NamedHttpFilterConfigFactory {
@@ -47,6 +48,8 @@ class HttpDynamicDelayDecoderFilterConfigFactory
4748
}
4849
};
4950

51+
} // namespace
52+
5053
static Envoy::Registry::RegisterFactory<HttpDynamicDelayDecoderFilterConfigFactory,
5154
Envoy::Server::Configuration::NamedHttpFilterConfigFactory>
5255
register_;

0 commit comments

Comments
 (0)