-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
golang: allow injecting extra data (#38362)
<!-- !!!ATTENTION!!! If you are fixing *any* crash or *any* potential security issue, *do not* open a pull request in this repo. Please report the issue via emailing envoy-security@googlegroups.com where the issue will be triaged appropriately. Thank you in advance for helping to keep Envoy secure. !!!ATTENTION!!! For an explanation of how to fill out the fields, please see the relevant section in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md) --> Commit Message: golang: allow injecting extra data Additional Description: This PR adds a feature that allows users to flush the data immediately when processing the data asynchronously. Risk Level: Low Testing: Integration test Docs Changes: Release Notes: Platform Specific Features: [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] Signed-off-by: spacewander <spacewanderlzx@gmail.com>
- Loading branch information
1 parent
0b83af5
commit 6c11eac
Showing
15 changed files
with
434 additions
and
1 deletion.
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
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
21 changes: 21 additions & 0 deletions
21
contrib/golang/filters/http/test/test_data/bufferinjectdata/BUILD
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,21 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
licenses(["notice"]) # Apache 2 | ||
|
||
go_library( | ||
name = "bufferinjectdata", | ||
srcs = [ | ||
"config.go", | ||
"filter.go", | ||
], | ||
cgo = True, | ||
importpath = "example.com/test-data/bufferinjectdata", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//contrib/golang/common/go/api", | ||
"//contrib/golang/filters/http/source/go/pkg/http", | ||
"@com_github_cncf_xds_go//xds/type/v3:type", | ||
"@org_golang_google_protobuf//types/known/anypb", | ||
"@org_golang_google_protobuf//types/known/structpb", | ||
], | ||
) |
39 changes: 39 additions & 0 deletions
39
contrib/golang/filters/http/test/test_data/bufferinjectdata/config.go
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,39 @@ | ||
package bufferinjectdata | ||
|
||
import ( | ||
"google.golang.org/protobuf/types/known/anypb" | ||
|
||
"github.com/envoyproxy/envoy/contrib/golang/common/go/api" | ||
"github.com/envoyproxy/envoy/contrib/golang/filters/http/source/go/pkg/http" | ||
) | ||
|
||
const Name = "bufferinjectdata" | ||
|
||
func init() { | ||
http.RegisterHttpFilterFactoryAndConfigParser(Name, filterFactory, &parser{}) | ||
} | ||
|
||
type config struct { | ||
} | ||
|
||
type parser struct { | ||
} | ||
|
||
func (p *parser) Parse(any *anypb.Any, callbacks api.ConfigCallbackHandler) (interface{}, error) { | ||
return &config{}, nil | ||
} | ||
|
||
func (p *parser) Merge(parent interface{}, child interface{}) interface{} { | ||
return child | ||
} | ||
|
||
func filterFactory(c interface{}, callbacks api.FilterCallbackHandler) api.StreamFilter { | ||
conf, ok := c.(*config) | ||
if !ok { | ||
panic("unexpected config type") | ||
} | ||
return &filter{ | ||
callbacks: callbacks, | ||
config: conf, | ||
} | ||
} |
Oops, something went wrong.