-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Feature: Golang Http Tcp Bridge #36667
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: duxin40 <duxin40@gamil.com>
support golang tcp extension for http2tcp
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
I will add unit tests for these codes and fix errors related to unit tests. |
@doujiang24 could you take a look and check if the direction looks good? thanks! |
/assign @doujiang24 Per discussion in #35749 |
@duxin40 cannot be assigned to this issue. |
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.
Better add a simple example that use Golang to implement http => TCP protocol, to show how it could be for users for easier understanding.
It do not need to be runable, just a demo.
api/contrib/envoy/extensions/upstreams/http/tcp/golang/v3alpha/BUILD
Outdated
Show resolved
Hide resolved
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
} | ||
|
||
void TcpUpstream::encodeTrailers(const Envoy::Http::RequestTrailerMap&) { | ||
Buffer::OwnedImpl data; |
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.
ditto, we'd better golang convert trailers to data buffer, but we can just add a TODO for it now, it's not a common use case.
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.
got it, will finish it in the near future.
contrib/golang/upstreams/http/tcp/test/test_data/http2dubbo-example/README.md
Outdated
Show resolved
Hide resolved
…om response header in envoyGoOnUpstreamData Signed-off-by: duxin40 <duxin40@gamil.com>
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.
Sorry for the late, it's good enough to add more tests, including integration tests.
contrib/golang/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp/shim.go
Show resolved
Hide resolved
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
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.
Nice work, we are closer
contrib/golang/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp/shim.go
Outdated
Show resolved
Hide resolved
} | ||
|
||
func (f *requestMap) GetReq(key *C.httpRequest) *httpRequest { | ||
if v, ok := f.requests.Load(key); ok { |
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.
Can we introduce the worker_id
as #31987? it could be much better performance when there are large envoy workers.
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.
it also could be marked as TODO, since this PR is big enough.
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.
okay, let's mark it as a TODO, and i will optimize it in the near future~
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
/docs |
Docs for this Pull Request will be rendered here: https://storage.googleapis.com/envoy-pr/36667/docs/index.html The docs are (re-)rendered each time the CI |
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.
@duxin40 Thank you so much for your hard work and patience.
Please run the tests in the asan mode, in your local dev, here is the command from my side:
ENVOY_DOCKER_BUILD_DIR=/path/to/envoy-bazel-cache \
GOPROXY='https://goproxy.cn' \
bash -x ci/run_envoy_docker.sh 'bash -x ci/do_ci.sh asan'
It's so good enough to merge from my side.
@mattklein123 @wbpcode could you please take another look at this PR.
It is a bit large, but it's also a very important feature to extend HTTP <-> RPC.
.. literalinclude:: /_configs/go/golang-http-tcp-bridge-with-config.yaml | ||
:language: yaml | ||
:linenos: | ||
:lines: 38-50 |
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.
seems the line number is incorrect? see: https://storage.googleapis.com/envoy-pr/a4ef3f6/docs/configuration/http/tcp_bridge/golang.html
Signed-off-by: duxin40 <33946910+duxin40@users.noreply.github.com>
Signed-off-by: duxin40 <duxin40@gamil.com>
Docs for this Pull Request will be rendered here: https://storage.googleapis.com/envoy-pr/36667/docs/index.html The docs are (re-)rendered each time the CI |
As mentioned in the proposal: #35749 , this PR is to support using Golang to extend TCP upstream proxy, to make changes to connections and data messages in the http2tcp situation of envoy.
(this PR does)
Here is my thought about Golang extension function points:
What we can do with this Golang extension:
With this golang extension, developers can quickly get started with envoy and use golang to implement http2tcp such as http2dubbo、http2rpc.
Commit Message: support Golang TCP Upstream Extension for http2tcp on Envoy
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]