Thrift: Payload to metadata filter (#23409)
This filter is configured with request_rules that will be matched against requests. A field_selector of a rule represents the head of a linked list, each node of the linked list has a name for logging and an id for matching. The field_selector is tied to a payload field when the linked list corresponds to a downward path which rooted in the top-level of the request message structure. on_present is triggered when corresponding the payload is present. Otherwise, on_missing is triggered. This filter is designed to support payload passthrough. By performing payload to metadata filter can do deserialization once, and pass the metadata to other filters. This means that load balancing decisions, consumed from log and routing could all use payload information with a single parse. Also notably performing the parsing in payload passthrough buffer will mean deserialization once and not re-serializing, which is the most performant outcome. Risk Level: low Testing: unit Docs Changes: multiple rst Fixes #23322 Signed-off-by: kuochunghsu <kuochunghsu@pinterest.com> Mirrored from https://github.com/envoyproxy/envoy @ cd208a5dbc281dcc27a8155a210037267c08ff6fpull/626/head
parent
e2bb2f4b3b
commit
062d91871b
4 changed files with 114 additions and 0 deletions
@ -0,0 +1,12 @@ |
||||
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. |
||||
|
||||
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") |
||||
|
||||
licenses(["notice"]) # Apache 2 |
||||
|
||||
api_proto_package( |
||||
deps = [ |
||||
"//envoy/type/matcher/v3:pkg", |
||||
"@com_github_cncf_udpa//udpa/annotations:pkg", |
||||
], |
||||
) |
@ -0,0 +1,100 @@ |
||||
syntax = "proto3"; |
||||
|
||||
package envoy.extensions.filters.network.thrift_proxy.filters.payload_to_metadata.v3; |
||||
|
||||
import "envoy/type/matcher/v3/regex.proto"; |
||||
|
||||
import "udpa/annotations/status.proto"; |
||||
import "validate/validate.proto"; |
||||
|
||||
option java_package = "io.envoyproxy.envoy.extensions.filters.network.thrift_proxy.filters.payload_to_metadata.v3"; |
||||
option java_outer_classname = "PayloadToMetadataProto"; |
||||
option java_multiple_files = true; |
||||
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/v3;payload_to_metadatav3"; |
||||
option (udpa.annotations.file_status).package_version_status = ACTIVE; |
||||
|
||||
// [#protodoc-title: Payload-To-Metadata Filter] |
||||
// |
||||
// The configuration for transforming payloads into metadata. This is useful |
||||
// for matching load balancer subsets, logging, etc. |
||||
// |
||||
// Payload to Metadata :ref:`configuration overview <config_thrift_filters_payload_to_metadata>`. |
||||
// [#extension: envoy.filters.thrift.payload_to_metadata] |
||||
|
||||
message PayloadToMetadata { |
||||
enum ValueType { |
||||
STRING = 0; |
||||
NUMBER = 1; |
||||
} |
||||
|
||||
// [#next-free-field: 6] |
||||
message KeyValuePair { |
||||
// The namespace — if this is empty, the filter's namespace will be used. |
||||
string metadata_namespace = 1; |
||||
|
||||
// The key to use within the namespace. |
||||
string key = 2 [(validate.rules).string = {min_len: 1}]; |
||||
|
||||
oneof value_type { |
||||
// The value to pair with the given key. |
||||
// |
||||
// When used for on_present case, if value is non-empty it'll be used instead |
||||
// of the field value. If both are empty, the field value is used as-is. |
||||
// |
||||
// When used for on_missing case, a non-empty value must be provided. |
||||
string value = 3; |
||||
|
||||
// If present, the header's value will be matched and substituted with this. |
||||
// If there is no match or substitution, the field value is used as-is. |
||||
// |
||||
// This is only used for on_present. |
||||
type.matcher.v3.RegexMatchAndSubstitute regex_value_rewrite = 4; |
||||
} |
||||
|
||||
// The value's type — defaults to string. |
||||
ValueType type = 5 [(validate.rules).enum = {defined_only: true}]; |
||||
} |
||||
|
||||
// A Rule defines what metadata to apply when a field is present or missing. |
||||
// [#next-free-field: 6] |
||||
message Rule { |
||||
oneof match_specifier { |
||||
option (validate.required) = true; |
||||
|
||||
// If specified, the route must exactly match the request method name. As a special case, |
||||
// an empty string matches any request method name. |
||||
string method_name = 1; |
||||
|
||||
// If specified, the route must have the service name as the request method name prefix. |
||||
// As a special case, an empty string matches any service name. Only relevant when service |
||||
// multiplexing. |
||||
string service_name = 2; |
||||
} |
||||
|
||||
// Specifies that a match will be performed on the value of a field. |
||||
FieldSelector field_selector = 3 [(validate.rules).message = {required: true}]; |
||||
|
||||
// If the field is present, apply this metadata KeyValuePair. |
||||
KeyValuePair on_present = 4; |
||||
|
||||
// If the field is missing, apply this metadata KeyValuePair. |
||||
// |
||||
// The value in the KeyValuePair must be set, since it'll be used in lieu |
||||
// of the missing field value. |
||||
KeyValuePair on_missing = 5; |
||||
} |
||||
|
||||
message FieldSelector { |
||||
// field name to log |
||||
string name = 1 [(validate.rules).string = {min_len: 1}]; |
||||
|
||||
// field id to match |
||||
int32 id = 2 [(validate.rules).int32 = {lte: 32767 gte: -32768}]; |
||||
|
||||
// next node of the field selector |
||||
FieldSelector child = 3; |
||||
} |
||||
|
||||
// The list of rules to apply to requests. |
||||
repeated Rule request_rules = 1 [(validate.rules).repeated = {min_items: 1}]; |
||||
} |
Loading…
Reference in new issue