-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f6b6ba
commit 2fdc8ac
Showing
25 changed files
with
885 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Matches | ||
|
||
The `Matches` filter's job is to provide a mechanism to change behaviour based | ||
on dynamic metadata. This filter behaves similarly to the `match` expression | ||
in Rust or `switch` statements in other languages. | ||
|
||
#### Filter name | ||
```text | ||
quilkin.extensions.filters.matches.v1alpha1.Matches | ||
``` | ||
|
||
### Configuration Examples | ||
```rust | ||
# let yaml = " | ||
version: v1alpha1 | ||
static: | ||
endpoints: | ||
- address: 127.0.0.1:26000 | ||
- address: 127.0.0.1:26001 | ||
filters: | ||
- name: quilkin.extensions.filters.capture_bytes.v1alpha1.CaptureBytes | ||
config: | ||
strategy: PREFIX | ||
metadataKey: myapp.com/token | ||
size: 3 | ||
remove: false | ||
- name: quilkin.extensions.filters.matches.v1alpha1.Matches | ||
config: | ||
on_read: | ||
metadataKey: myapp.com/token | ||
branches: | ||
- value: abc | ||
filter: quilkin.extensions.filters.concatenate_bytes.v1alpha1.ConcatenateBytes | ||
config: | ||
on_read: APPEND | ||
bytes: eHl6 # "xyz" | ||
# "; | ||
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap(); | ||
# assert_eq!(config.source.get_static_filters().unwrap().len(), 1); | ||
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap(); | ||
``` | ||
|
||
View the [Matches](../../api/quilkin/filters/matches/struct.Config.html) filter documentation for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
proto/quilkin/extensions/filters/matches/v1alpha1/matches.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package quilkin.extensions.filters.matches.v1alpha1; | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
import "google/protobuf/struct.proto"; | ||
import "google/protobuf/any.proto"; | ||
|
||
message Matches { | ||
message Branch { | ||
google.protobuf.Value value = 1; | ||
google.protobuf.StringValue filter = 2; | ||
optional google.protobuf.Any config = 3; | ||
} | ||
|
||
message FallthroughFilter { | ||
google.protobuf.StringValue filter = 2; | ||
optional google.protobuf.Any config = 3; | ||
} | ||
|
||
message DirectionalConfig { | ||
google.protobuf.StringValue metadata_key = 1; | ||
repeated Branch branches = 2; | ||
oneof fallthrough { | ||
google.protobuf.NullValue pass = 3; | ||
google.protobuf.NullValue drop = 4; | ||
FallthroughFilter filter = 5; | ||
} | ||
} | ||
|
||
optional DirectionalConfig on_read = 1; | ||
optional DirectionalConfig on_write = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.