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

Sync Rate Limiter APIs to v0.1.8 #39

Merged
merged 1 commit into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 79 additions & 1 deletion api/rate-limiter/v1alpha1/ratelimit.proto
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,81 @@ message Action {
repeated HeaderMatcher headers = 3; // [(validate.rules).repeated .min_items = 1];
}

// The following descriptor entry is appended when the metadata contains a key value:
// ("<descriptor_key>", "<value_queried_from_metadata>")
message MetaData {
enum Source {
// Query [dynamic metadata](https://www.envoyproxy.io/docs/envoy/latest/configuration/advanced/well_known_dynamic_metadata#well-known-dynamic-metadata).
DYNAMIC = 0;

// Query [route entry metadata](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-field-config-route-v3-route-metadata).
ROUTE_ENTRY = 1;
}

// MetadataKey provides a general interface using `key` and `path` to retrieve value from
// [`Metadata`](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/base.proto#envoy-v3-api-msg-config-core-v3-metadata).
//
// For example, for the following Metadata:
//
// ```yaml
// filter_metadata:
// envoy.xxx:
// prop:
// foo: bar
// xyz:
// hello: envoy
// ```
//
// The following MetadataKey will retrieve a string value "bar" from the Metadata.
//
// ```yaml
// key: envoy.xxx
// path:
// - key: prop
// - key: foo
// ```
//
message MetadataKey {

// Specifies the segment in a path to retrieve value from Metadata.
// Currently it is only supported to specify the key, i.e. field name, as one segment of a path.
message PathSegment {
oneof segment {
// option (validate.required) = true;

// Required. If specified, use the key to retrieve the value in a Struct.
string key = 1; // [(validate.rules).string = {min_len: 1}];
}
}

// Required. The key name of Metadata to retrieve the Struct from the metadata.
// Typically, it represents a builtin subsystem or custom extension.
string key = 1; // [(validate.rules).string = {min_len: 1}];

// Must have at least one element. The path to retrieve the Value from the Struct. It can be a prefix or a full path,
// e.g. ``[prop, xyz]`` for a struct or ``[prop, foo]`` for a string in the example,
// which depends on the particular scenario.
//
// Note: Due to that only the key type segment is supported, the path can not specify a list
// unless the list is the last segment.
repeated PathSegment path = 2; // [(validate.rules).repeated = {min_items: 1}];
}

// Required. The key to use in the descriptor entry.
string descriptor_key = 1; // [(validate.rules).string = {min_len: 1}];

// Required. Metadata struct that defines the key and path to retrieve the string value. A match will
// only happen if the value in the metadata is of type string.
MetadataKey metadata_key = 2; // [(validate.rules).message = {required: true}];

// An optional value to use if *metadata_key* is empty. If not set and
// no value is present under the metadata_key then no descriptor is generated.
string default_value = 3;

// Source of metadata
Source source = 4; // [(validate.rules).enum = {defined_only: true}];
}

oneof action_specifier {

// Rate limit on source cluster.
Expand All @@ -466,5 +541,8 @@ message Action {

// Rate limit on the existence of request headers.
HeaderValueMatch header_value_match = 6;

// Rate limit on metadata.
MetaData metadata = 8;
}
}
}
137 changes: 137 additions & 0 deletions pkg/api/ratelimit.solo.io/v1alpha1/ratelimit.pb.equal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading