-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding config factory #522
Conversation
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
a global request generator. Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Adding comments. Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
…TestForRequestSourceFactory Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
request source. Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
} | ||
|
||
// Increment the counter and get the request_option from the list for the current iteration. | ||
auto index = lambda_counter % options_list_->options_size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood.
// Increment the counter and get the request_option from the list for the current iteration. | ||
auto index = lambda_counter % options_list_->options_size(); | ||
nighthawk::client::RequestOptions request_option = options_list_->options().at(index); | ||
lambda_counter++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood
if (content_length > 0) { | ||
header->setContentLength(content_length); | ||
} | ||
for (const auto& option_header : request_option.request_headers()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood.
request_max_(request_max) {} | ||
|
||
RequestGenerator RequestOptionsListRequestSource::get() { | ||
uint32_t counter = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can do that.
util.loadFromFile(config.file_path(), options_list_, | ||
Envoy::ProtobufMessage::getStrictValidationVisitor(), *api, true); | ||
} | ||
temp_list->CopyFrom(options_list_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought it made more sense for the requestSource to have ownership of the list, but I think that the factory does have a longer lifetime than the requestSources it generates, so that probably would work.
const uint32_t request_max_; | ||
}; | ||
|
||
// Factory that creates a RequestOptionsListRequestSource from a FileBasedPluginConfig proto. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a typo. I wanted this to be a more generic version of the RequestOptionsListRequestSource since it seemed the more versatile option.
// produced by get() will use options from the options_list to overwrite values in the header, and | ||
// create new requests. if request_max is greater than the length of options_list, it will loop. | ||
// This is not thread safe. | ||
class RequestOptionsListRequestSource : public RequestSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt like it made sense for both the RequestSource and the factory that makes the requestSource to live in the same file together, I can move it into its own library if you prefer.
// load the file from memory and subsequent calls just make a copy of the options_list that was | ||
// already loaded. The FileBasedRequestSourcePluginConfigFactory will not work with multiple | ||
// different files for this reason. | ||
RequestSourcePtr createRequestSourcePlugin(const Envoy::Protobuf::Message& message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
@@ -27,6 +27,10 @@ | |||
#include "api/client/service.pb.h" | |||
#include "api/client/service_mock.grpc.pb.h" | |||
|
|||
#include "gtest/gtest.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully I've reverted the change that introduced these.
|
||
// Factory that creates a RequestOptionsListRequestSource from a FileBasedPluginConfig proto. | ||
// Registered as an Envoy plugin. | ||
// Implementation of RequestSourceConfigFactory which produces a RequestSource that keeps an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I'm doing a very good job at this, but I'll do my best.
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for iterating on this. This is now a complete review and we only have few minor comments left to address.
@@ -0,0 +1,55 @@ | |||
// Implementations of RequestSourceConfigFactory and the RequestSources that those factories make. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to say something else here, i.e. we should talk about the stub plugin which is implemented in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack.
// mechanism using a minimal version of plugin that does not require a more complicated proto or | ||
// file reading. | ||
message StubPluginConfig { | ||
// test input value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had a comment thread about improving this comment, but looks like the it wasn't actually done. Repeating the comment:
Can we improve this comment? We could say what the input argument is for / what does the plugin do with it. It raises a question as to why a plugin that does nothing need an input argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I thought I fixed it by making it do something.
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
/retest |
🔨 rebuilding |
Adding config factories for RequestSourcePlugins. Specifically starting with FileBasedRequestSourcePlugin. These will be provided as options to be used inside RequestSourceFactory. This is part of a series of PRs for providing the ability to use statically linked requestSources.