Skip to content
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

Merged
merged 131 commits into from
Oct 5, 2020
Merged

Conversation

wjuan-AFK
Copy link
Contributor

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.

wjuan-AFK added 30 commits July 15, 2020 20:04
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]>
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();
Copy link
Contributor Author

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++;
Copy link
Contributor Author

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()) {
Copy link
Contributor Author

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;
Copy link
Contributor Author

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_);
Copy link
Contributor Author

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.
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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,
Copy link
Contributor Author

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"
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@wjuan-AFK wjuan-AFK requested a review from mum4k October 1, 2020 05:46
@wjuan-AFK wjuan-AFK added waiting-for-review A PR waiting for a review. and removed waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. labels Oct 1, 2020
Copy link
Collaborator

@mum4k mum4k left a 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.
Copy link
Collaborator

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.

Copy link
Contributor Author

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.
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@mum4k mum4k added waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. and removed waiting-for-review A PR waiting for a review. labels Oct 1, 2020
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
Signed-off-by: William Juan <[email protected]>
@wjuan-AFK
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: clang_tidy (failed build)

🐱

Caused by: a #522 (comment) was created by @wjuan-AFK.

see: more, trace.

@wjuan-AFK wjuan-AFK added waiting-for-review A PR waiting for a review. and removed waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. labels Oct 5, 2020
@mum4k mum4k merged commit a358469 into envoyproxy:master Oct 5, 2020
@wjuan-AFK wjuan-AFK deleted the AddingConfigFactory branch June 9, 2021 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-review A PR waiting for a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants