Skip to content

Commit

Permalink
Feature: Golang Http Tcp Bridge (#36667)
Browse files Browse the repository at this point in the history
As mentioned in the proposal:
envoyproxy/envoy#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:
1. Support encoding message processing for upstream TCP requests (route
and cluster have been determined, and targeted message processing can be
performed for route and cluster)
2. Support the handling of conn connection status during the encoding
stage of upstream TCP requests (for example, by setting end_stream=false
to avoid envoy semi connected status)
3. Support decoding message processing and aggregation for upstream TCP
response in onUpstreamData.(for example, by setting end_stream=true to
indicate that the message is encapsulated and can be passed to
downstream)
4. Aggregate the tcp messages received multiple times by onUpstreamData
of tcp response.
5. Support obtaining route and cluster information, which can be
referenced for targeted processing in the above stages.

### 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.

Signed-off-by: duxin40 <duxin40@gamil.com>
Signed-off-by: duxin40 <33946910+duxin40@users.noreply.github.com>

Mirrored from https://github.com/envoyproxy/envoy @ b034c57c7328237a4b12c7d5c2ca41b19569c9b5
  • Loading branch information
update-envoy[bot] committed Jan 27, 2025
1 parent 7714d2d commit 64bdd0e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ proto_library(
"//contrib/envoy/extensions/regex_engines/hyperscan/v3alpha:pkg",
"//contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha:pkg",
"//contrib/envoy/extensions/tap_sinks/udp_sink/v3alpha:pkg",
"//contrib/envoy/extensions/upstreams/http/tcp/golang/v3alpha:pkg",
"//contrib/envoy/extensions/vcl/v3alpha:pkg",
"//envoy/admin/v3:pkg",
"//envoy/config/accesslog/v3:pkg",
Expand Down
12 changes: 12 additions & 0 deletions contrib/envoy/extensions/upstreams/http/tcp/golang/v3alpha/BUILD
Original file line number Diff line number Diff line change
@@ -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 = [
"@com_github_cncf_xds//udpa/annotations:pkg",
"@com_github_cncf_xds//xds/annotations/v3:pkg",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";

package envoy.extensions.upstreams.http.tcp.golang.v3alpha;

import "google/protobuf/any.proto";

import "xds/annotations/v3/status.proto";

import "udpa/annotations/status.proto";
import "validate/validate.proto";

option java_package = "io.envoyproxy.envoy.extensions.upstreams.http.tcp.golang.v3alpha";
option java_outer_classname = "GolangProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/contrib/envoy/extensions/upstreams/http/tcp/golang/v3alpha";
option (udpa.annotations.file_status).package_version_status = ACTIVE;
option (xds.annotations.v3.file_status).work_in_progress = true;

// [#protodoc-title: Golang]
//
// This bridge enables an Http client to connect to a TCP server via a Golang plugin, facilitating Protocol Convert from HTTP to any RPC protocol in Envoy.
//
// For an overview of the Golang HTTP TCP bridge please see the :ref:`configuration reference documentation <config_http_tcp_bridge_golang>`.
// [#extension: envoy.upstreams.http.tcp.golang]

// [#extension-category: envoy.upstreams]
message Config {
// Globally unique ID for a dynamic library file.
string library_id = 1 [(validate.rules).string = {min_len: 1}];

// Path to a dynamic library implementing the
// :repo:`HttpTcpBridge API <contrib/golang/common/go/api.HttpTcpBridge>`
// interface.
string library_path = 2 [(validate.rules).string = {min_len: 1}];

// Globally unique name of the Go plugin.
//
// This name **must** be consistent with the name registered in ``tcp::RegisterHttpTcpBridgeFactoryAndConfigParser``
//
string plugin_name = 3 [(validate.rules).string = {min_len: 1}];

// Configuration for the Go plugin.
//
// .. note::
// This configuration is only parsed in the Golang plugin, and is therefore not validated
// by Envoy.
//
// See the :repo:`HttpTcpBridge API <contrib/golang/common/go/api/filter.go>`
// for more information about how the plugin's configuration data can be accessed.
//
google.protobuf.Any plugin_config = 4;
}
1 change: 1 addition & 0 deletions versioning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ proto_library(
"//contrib/envoy/extensions/regex_engines/hyperscan/v3alpha:pkg",
"//contrib/envoy/extensions/router/cluster_specifier/golang/v3alpha:pkg",
"//contrib/envoy/extensions/tap_sinks/udp_sink/v3alpha:pkg",
"//contrib/envoy/extensions/upstreams/http/tcp/golang/v3alpha:pkg",
"//contrib/envoy/extensions/vcl/v3alpha:pkg",
"//envoy/admin/v3:pkg",
"//envoy/config/accesslog/v3:pkg",
Expand Down

0 comments on commit 64bdd0e

Please sign in to comment.