-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Remove substitution_formatter_base.h #45369
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,121 @@ | ||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "envoy/common/pure.h" | ||
| #include "envoy/config/typed_config.h" | ||
| #include "envoy/formatter/http_formatter_context.h" | ||
| #include "envoy/formatter/substitution_formatter_base.h" | ||
| #include "envoy/http/header_map.h" | ||
| #include "envoy/server/factory_context.h" | ||
| #include "envoy/stream_info/stream_info.h" | ||
|
|
||
| #include "source/common/protobuf/protobuf.h" | ||
|
|
||
| #include "absl/strings/string_view.h" | ||
| #include "absl/types/optional.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Formatter {} // namespace Formatter | ||
| namespace Formatter { | ||
|
|
||
| /** | ||
| * Interface for multiple protocols/modules formatters. | ||
| */ | ||
| class Formatter { | ||
| public: | ||
| virtual ~Formatter() = default; | ||
|
|
||
| /** | ||
| * Return a formatted substitution line. | ||
| * @param context supplies the formatter context. | ||
| * @param stream_info supplies the stream info. | ||
| * @return std::string string containing the complete formatted substitution line. | ||
| */ | ||
| virtual std::string format(const Context& context, | ||
| const StreamInfo::StreamInfo& stream_info) const PURE; | ||
| }; | ||
|
|
||
| using FormatterPtr = std::unique_ptr<Formatter>; | ||
| using FormatterConstSharedPtr = std::shared_ptr<const Formatter>; | ||
|
|
||
| /** | ||
| * Interface for multiple protocols/modules formatter providers. | ||
| */ | ||
| class FormatterProvider { | ||
| public: | ||
| virtual ~FormatterProvider() = default; | ||
|
|
||
| /** | ||
| * Format the value with the given context and stream info. | ||
| * @param context supplies the formatter context. | ||
| * @param stream_info supplies the stream info. | ||
| * @return absl::optional<std::string> optional string containing a single value extracted from | ||
| * the given context and stream info. | ||
| */ | ||
| virtual absl::optional<std::string> format(const Context& context, | ||
| const StreamInfo::StreamInfo& stream_info) const PURE; | ||
|
|
||
| /** | ||
| * Format the value with the given context and stream info. | ||
| * @param context supplies the formatter context. | ||
| * @param stream_info supplies the stream info. | ||
| * @return Protobuf::Value containing a single value extracted from the given | ||
| * context and stream info. | ||
| */ | ||
| virtual Protobuf::Value formatValue(const Context& context, | ||
| const StreamInfo::StreamInfo& stream_info) const PURE; | ||
| }; | ||
|
|
||
| using FormatterProviderPtr = std::unique_ptr<FormatterProvider>; | ||
|
|
||
| class CommandParser { | ||
| public: | ||
| virtual ~CommandParser() = default; | ||
|
|
||
| /** | ||
| * Return a FormatterProviderBasePtr if command arg and max_length are correct for the formatter | ||
| * provider associated with command. | ||
| * @param command command name. | ||
| * @param command_arg command specific argument. Empty if no argument is provided. | ||
| * @param max_length length to which the output produced by FormatterProvider | ||
| * should be truncated to (optional). | ||
| * | ||
| * @return FormattterProviderPtr substitution provider for the parsed command. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove a "t" |
||
| */ | ||
|
Comment on lines
+77
to
+85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment for * Return a FormatterProviderPtr if command arg and max_length are correct for the formatter
* provider associated with command.
* @param command command name.
* @param command_arg command specific argument. Empty if no argument is provided.
* @param max_length length to which the output produced by FormatterProvider
* should be truncated to (optional).
*
* @return FormatterProviderPtr substitution provider for the parsed command.
*/ |
||
| virtual FormatterProviderPtr parse(absl::string_view command, absl::string_view command_arg, | ||
| absl::optional<size_t> max_length) const PURE; | ||
| }; | ||
|
|
||
| using CommandParserPtr = std::unique_ptr<CommandParser>; | ||
| using CommandParserPtrVector = std::vector<CommandParserPtr>; | ||
|
|
||
| class CommandParserFactory : public Config::TypedFactory { | ||
| public: | ||
| /** | ||
| * Creates a particular CommandParser implementation. | ||
| * | ||
| * @param config supplies the configuration for the command parser. | ||
| * @param context supplies the factory context. | ||
| * @return CommandParserPtr the CommandParser which will be used in | ||
| * SubstitutionFormatParser::parse() when evaluating an access log format string. | ||
| */ | ||
| virtual CommandParserPtr | ||
| createCommandParserFromProto(const Protobuf::Message& config, | ||
| Server::Configuration::GenericFactoryContext& context) PURE; | ||
|
|
||
| std::string category() const override { return "envoy.formatter"; } | ||
| }; | ||
|
|
||
| class BuiltInCommandParserFactory : public Config::UntypedFactory { | ||
| public: | ||
| std::string category() const override { return "envoy.built_in_formatters"; } | ||
|
|
||
| /** | ||
| * Creates a particular CommandParser implementation. | ||
| */ | ||
| virtual CommandParserPtr createCommandParser() const PURE; | ||
| }; | ||
|
|
||
| } // namespace Formatter | ||
| } // namespace Envoy | ||
This file was deleted.
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.
FormatterProviderPtr