Open eric846 opened 4 years ago
Hah, curious to hear what others think about this, but my 2p is that I like this. IMHO the extra complexity introduced by the templating is worth it, as this saves annoying and repetitive bootstrapping code. Also, maybe this could be very useful in TEST_P
type tests to check expected behaviour across implementations.
(for those who'd like hands on with the PoC @eric846 posted above: I had to #include <string>
to get it to build.)
Investigate strongly typed
ConfigValidator
Can the
ConfigValidator
[0] interface be rewritten somehow so that it knows the plugin-specific proto type, rather than having to try unpacking a Message?[0] https://github.com/envoyproxy/nighthawk/blob/master/include/nighthawk/adaptive_load/config_validator.h
Create a templatized helper for the following
(for all values of
LinearScoringFunctionConfig
)Make it easy to create a
TypedExtensionConfig
for a given pluginTypedExtensionConfig
[1] has fieldsname
andtyped_config
. It costs multiple lines of code to set the fields of the plugin-specific config, pack it into anAny
, and setname
andtyped_config
on the final proto. And there is no guarantee that you used a config proto that matches the plugin name.[1] https://github.com/envoyproxy/envoy/blob/e8216a8cf79c54e3e0a77ab729ebf27f4e79eb1b/api/envoy/config/core/v3/extension.proto
It's easy to make a helper function:
You would call it like:
But is there a way to avoid having both the plugin name and the type as inputs, which could be mismatched?
What if the factory implemented a
function that returned the associated config proto type? EDIT: I realized a real proto value probably can't beconstexpr
constexpr
, but fortunately it still compiles withoutconstexpr
.This is the best I could come up with: