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

Feature: Golang Http Tcp Bridge #36667

Open
wants to merge 73 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
01813c1
support golang tcp extension for http2tcp
Oct 17, 2024
ed300bb
Merge pull request #8 from duxin40/main-merge
duxin40 Oct 17, 2024
1386488
merge code of opensource main
Oct 17, 2024
6946c93
rollback go package version to follow opensource code
Oct 17, 2024
7ae6768
fix error for tests
Oct 17, 2024
a60f4fa
fix error for tests
Oct 17, 2024
e8234db
add example for http2dubbo by golang extension on envoy
Oct 21, 2024
17bc4a4
delete unused code
Oct 21, 2024
4b5880c
add new blank line
Oct 21, 2024
4abfe0a
Optimize http2dubbo example
Oct 21, 2024
da41130
format example code
Oct 21, 2024
1c35411
format example code
Oct 21, 2024
98e1589
support EncodeHeaders for goalng tcp upstream extension
Oct 22, 2024
9bb967c
1.support set buffer for writing upstream data 2.support specify cust…
Oct 30, 2024
0b7fde5
1. add example for http2dubbo by golang-tcp-upstream-extension. 2. op…
Oct 31, 2024
5898f45
optimize http2dubbo example
Nov 1, 2024
7c21160
optimize annotation for http2dubbo example
Nov 1, 2024
de5d85d
delete ununsed file
Nov 1, 2024
1d2d0ac
optimize annotation for http2dubbo example
Nov 1, 2024
152118b
support unique ptr for tcp_upstream and tcp_conn_pool
Nov 11, 2024
08bb49e
optimize code
Nov 11, 2024
c92c078
1.add destructor func for tcp upstream and filter. 2.optimize code
Nov 12, 2024
0cc11de
optimize logic for upstream config
Nov 12, 2024
8187006
optimize and delete unuse code
Nov 12, 2024
c056752
1. remove weak_filter of async, and use sync clearly bteween go and c++.
Nov 20, 2024
28b8111
delete unused code
Nov 20, 2024
2d1abdd
simplify & optimize status and state
Nov 21, 2024
185818c
support full-duplex
Nov 21, 2024
9dd2d0c
add notes for status and fix bug
Nov 22, 2024
65e4796
add docks for golang tcp upstream filter
Nov 28, 2024
1260dd7
optimize envoyGoTcpUpstreamDestroyPluginConfig and envoyGoOnTcpUpstre…
Dec 2, 2024
bc83d9b
delete state.doDataList in encodeHeaders and encodeData
Dec 2, 2024
8cf3668
optimize annotation
Dec 2, 2024
be318e2
delete unused go code
Dec 2, 2024
75a9c41
delete unused code
Dec 2, 2024
d3a44cf
optimize code
Dec 2, 2024
58d24c3
update doc and example
Dec 5, 2024
24480de
delete processState
Dec 9, 2024
663afc8
Revert "delete processState"
Dec 11, 2024
a8fa562
optimize code
Dec 13, 2024
2c47930
Merge branch 'main' into main
duxin40 Dec 13, 2024
6872fc5
optimize code
Dec 13, 2024
e7eb50b
delete unused log
Dec 13, 2024
143875b
optimize about mutex and panic
Dec 14, 2024
0714aa7
simplfy logic about panic
Dec 15, 2024
6541f8d
optimize code
Dec 17, 2024
79401ba
optimize code
Dec 18, 2024
613a192
fix memory leaking
Dec 20, 2024
6d54120
optimize annoation
Dec 20, 2024
fd60445
format code
Dec 23, 2024
b32eabe
format code
Dec 23, 2024
7eaef90
fix ci problem
Dec 24, 2024
ac75587
remove lock since the plugin is sync-data-flow between c and go
Dec 31, 2024
4595abd
optimize code about panic
Jan 4, 2025
ad43324
terminate the stream when get panic
Jan 4, 2025
e314824
add integration test for golang-http-tcp-bridge
Jan 8, 2025
0dc67d0
fix ci problem
Jan 9, 2025
3869b18
optimize doc
Jan 9, 2025
1fbe401
format code
Jan 9, 2025
248045f
optimize annotation and merge multiple test go mods into a single one
Jan 13, 2025
c8942ba
add go.mod for test_data
Jan 13, 2025
e12539d
add a test for add_data
Jan 13, 2025
a4ef3f6
format code
Jan 13, 2025
914297e
Merge branch 'main' into main
duxin40 Jan 19, 2025
8adb4d8
format code and doc
Jan 19, 2025
eb33333
optimize doc
Jan 19, 2025
8baaee6
update doc and ci
Jan 20, 2025
74e0dc3
touch ci
Jan 20, 2025
1b09fd5
update doc
Jan 21, 2025
adae974
format doc
Jan 21, 2025
048e44f
optimize doc
Jan 22, 2025
b918a08
Merge branch 'main' into main
duxin40 Jan 22, 2025
2eec96e
optimize doc
Jan 22, 2025
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
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,47 @@
syntax = "proto3";

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

import "google/protobuf/any.proto";

import "validate/validate.proto";

import "udpa/annotations/status.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;

// [#protodoc-title: Tcp Connection Pool]

// A connection pool which forwards downstream HTTP as TCP to upstream,
// [#extension: envoy.upstreams.http.tcp]
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:`DownstreamFilter API <contrib/golang/common/go/api.DownstreamFilter>`
// interface.
// [#comment:TODO(wangfakang): Support for downloading libraries from remote repositories.]
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 ``network::RegisterNetworkFilterConfigFactory``
duxin40 marked this conversation as resolved.
Show resolved Hide resolved
//
string plugin_name = 3 [(validate.rules).string = {min_len: 1}];
duxin40 marked this conversation as resolved.
Show resolved Hide resolved

// Configuration for the Go plugin.
//
// .. note::
// This configuration is only parsed in the go plugin, and is therefore not validated
duxin40 marked this conversation as resolved.
Show resolved Hide resolved
// by Envoy.
//
// See the :repo:`DownstreamFilter 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 contrib/contrib_build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CONTRIB_EXTENSIONS = {
"envoy.filters.network.postgres_proxy": "//contrib/postgres_proxy/filters/network/source:config",
"envoy.filters.network.rocketmq_proxy": "//contrib/rocketmq_proxy/filters/network/source:config",
"envoy.filters.network.golang": "//contrib/golang/filters/network/source:config",
"envoy.upstreams.http.tcp.golang": "//contrib/golang/upstreams/http/tcp/source:config",

#
# Sip proxy
Expand Down
49 changes: 49 additions & 0 deletions contrib/golang/common/dso/dso.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,54 @@ void NetworkFilterDsoImpl::envoyGoFilterOnSemaDec(void* w) {
envoy_go_filter_on_sema_dec_(w);
}

TcpUpstreamDsoImpl::TcpUpstreamDsoImpl(const std::string dso_name)
: TcpUpstreamDso(dso_name) {
loaded_ &= dlsymInternal<decltype(envoy_go_on_tcp_upstream_config_)>(
envoy_go_on_tcp_upstream_config_, handler_, dso_name,
"envoyGoOnTcpUpstreamConfig");
loaded_ &= dlsymInternal<decltype(envoy_go_tcp_upstream_destroy_plugin_config_)>(
envoy_go_tcp_upstream_destroy_plugin_config_, handler_, dso_name,
"envoyGoTcpUpstreamDestroyPluginConfig");
loaded_ &= dlsymInternal<decltype(envoy_go_encode_header_)>(
envoy_go_encode_header_, handler_, dso_name, "envoyGoEncodeHeader");
loaded_ &= dlsymInternal<decltype(envoy_go_on_encode_data_)>(
envoy_go_on_encode_data_, handler_, dso_name, "envoyGoEncodeData");
loaded_ &= dlsymInternal<decltype(envoy_go_on_upstream_data_)>(
envoy_go_on_upstream_data_, handler_, dso_name, "envoyGoOnUpstreamData");
loaded_ &= dlsymInternal<decltype(envoy_go_on_tcp_upstream_destroy_)>(
envoy_go_on_tcp_upstream_destroy_, handler_, dso_name, "envoyGoOnTcpUpstreamDestroy");
}

GoUint64 TcpUpstreamDsoImpl::envoyGoOnTcpUpstreamConfig(httpConfig* p0) {
ASSERT(envoy_go_on_tcp_upstream_config_ != nullptr);
return envoy_go_on_tcp_upstream_config_(p0);
}

void TcpUpstreamDsoImpl::envoyGoTcpUpstreamDestroyPluginConfig(GoUint64 p0, GoInt p1) {
ASSERT(envoy_go_tcp_upstream_destroy_plugin_config_ != nullptr);
return envoy_go_tcp_upstream_destroy_plugin_config_(p0, p1);
}

void TcpUpstreamDsoImpl::envoyGoEncodeHeader(processState* p0, GoUint64 p1, GoUint64 p2,
GoUint64 p3) {
ASSERT(envoy_go_encode_header_ != nullptr);
return envoy_go_encode_header_(p0, p1, p2, p3);
}

GoUint64 TcpUpstreamDsoImpl::envoyGoEncodeData(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len) {
ASSERT(envoy_go_on_upstream_data_ != nullptr);
return envoy_go_on_encode_data_(state, end_stream, buf_ptr, buf_len);
}

GoUint64 TcpUpstreamDsoImpl::envoyGoOnUpstreamData(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len) {
ASSERT(envoy_go_on_upstream_data_ != nullptr);
return envoy_go_on_upstream_data_(state, end_stream, buf_ptr, buf_len);
}

void TcpUpstreamDsoImpl::envoyGoOnTcpUpstreamDestroy(httpRequest* p0, int p1) {
ASSERT(envoy_go_on_tcp_upstream_destroy_ != nullptr);
envoy_go_on_tcp_upstream_destroy_(p0, GoUint64(p1));
}

} // namespace Dso
} // namespace Envoy
54 changes: 54 additions & 0 deletions contrib/golang/common/dso/dso.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,60 @@ class NetworkFilterDsoImpl : public NetworkFilterDso {

using NetworkFilterDsoPtr = std::shared_ptr<NetworkFilterDso>;


class TcpUpstreamDso : public Dso {
public:
TcpUpstreamDso() = default;
TcpUpstreamDso(const std::string dso_name) : Dso(dso_name){};
~TcpUpstreamDso() override = default;

virtual GoUint64 envoyGoOnTcpUpstreamConfig(httpConfig* p0) PURE;

virtual void envoyGoTcpUpstreamDestroyPluginConfig(GoUint64 p0, GoInt p1) PURE;

virtual void envoyGoEncodeHeader(processState* p0, GoUint64 p1, GoUint64 p2, GoUint64 p3) PURE;

virtual GoUint64 envoyGoEncodeData(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len) PURE;

virtual GoUint64 envoyGoOnUpstreamData(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len) PURE;

virtual void envoyGoOnTcpUpstreamDestroy(httpRequest* p0, int p1) PURE;

};

class TcpUpstreamDsoImpl : public TcpUpstreamDso {
public:
TcpUpstreamDsoImpl(const std::string dso_name);
~TcpUpstreamDsoImpl() override = default;

GoUint64 envoyGoOnTcpUpstreamConfig(httpConfig* p0) override;

void envoyGoTcpUpstreamDestroyPluginConfig(GoUint64 p0, GoInt p1) override;

void envoyGoEncodeHeader(processState* p0, GoUint64 p1, GoUint64 p2, GoUint64 p3) override;

GoUint64 envoyGoEncodeData(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len) override;

GoUint64 envoyGoOnUpstreamData(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len) override;

void envoyGoOnTcpUpstreamDestroy(httpRequest* p0, int p1) override;

private:
GoUint64 (*envoy_go_on_tcp_upstream_config_)(httpConfig* p0) = {nullptr};

void (*envoy_go_tcp_upstream_destroy_plugin_config_)(GoUint64 p0, GoInt p1) = {nullptr};

void (*envoy_go_encode_header_)(processState* p0, GoUint64 p1, GoUint64 p2, GoUint64 p3) = {nullptr};

GoUint64 (*envoy_go_on_encode_data_)(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len) = {nullptr};

GoUint64 (*envoy_go_on_upstream_data_)(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len) = {nullptr};

void (*envoy_go_on_tcp_upstream_destroy_)(httpRequest* p0, GoUint64 p1) = {nullptr};
};

using TcpUpstreamDsoPtr = std::shared_ptr<TcpUpstreamDso>;

/*
* We do not unload a dynamic library once it is loaded. This is because
* Go shared library could not be unload by dlclose yet, see:
Expand Down
25 changes: 25 additions & 0 deletions contrib/golang/common/dso/libgolang.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,31 @@ extern GoUint64 envoyGoFilterOnUpstreamData(void* f, GoUint64 data_size, GoUint6
// github.com/envoyproxy/envoy/contrib/golang/filters/network/source/go/pkg/network.envoyGoFilterOnUpstreamEvent
extern void envoyGoFilterOnUpstreamEvent(void* f, GoInt event);

// go:linkname envoyGoOnTcpUpstreamConfig
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoOnTcpUpstreamConfig
extern GoUint64 envoyGoOnTcpUpstreamConfig(GoUint64 library_id_ptr, GoUint64 library_id_len,
GoUint64 config_ptr, GoUint64 config_len);

// go:linkname envoyGoTcpUpstreamDestroyHttpPluginConfig
// github.com/envoyproxy/envoy/contrib/golang/filters/http/source/go/pkg/http.envoyGoTcpUpstreamDestroyPluginConfig
extern void envoyGoTcpUpstreamDestroyPluginConfig(GoUint64 id, GoInt need_delay);

// go:linkname envoyGoEncodeHeader
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoEncodeHeader
extern void envoyGoEncodeHeader(processState* r, GoUint64 end_stream, GoUint64 header_num, GoUint64 header_bytes);

// go:linkname envoyGoEncodeData
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoEncodeData
extern GoUint64 envoyGoEncodeData(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len);

// go:linkname envoyGoOnUpstreamData
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoOnUpstreamData
extern GoUint64 envoyGoOnUpstreamData(processState* state, GoUint64 end_stream, GoUint64 buf_ptr, GoUint64 buf_len);

// go:linkname envoyGoOnTcpUpstreamDestroy
// github.com/envoyproxy/envoy/contrib/golang/filters/upstreams/http/tcp/source/go/pkg/upstreams/http/tcp.envoyGoOnTcpUpstreamDestroy
extern void envoyGoOnTcpUpstreamDestroy(httpRequest* r, GoUint64 reason);

#ifdef __cplusplus
}
#endif
12 changes: 12 additions & 0 deletions contrib/golang/common/go/api/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ CAPIStatus envoyGoFilterSetFilterState(void* wrapper, void* key, void* value, in
int life_span, int stream_sharing);
CAPIStatus envoyGoFilterGetFilterState(void* wrapper, void* key, void* value);

// tcp upstream
CAPIStatus envoyGoTcpUpstreamInfo(void* u, int info_type, void* ret);
CAPIStatus envoyGoTcpUpstreamConnEnableHalfClose(void* u, int enable_half_close);
CAPIStatus envoyGoTcpUpstreamGetHeader(void* s, void* key_data, int key_len, uint64_t* value_data, int* value_len);
CAPIStatus envoyGoTcpUpstreamCopyHeaders(void* s, void* strs, void* buf);
CAPIStatus envoyGoTcpUpstreamGetBuffer(void* s, uint64_t buffer, void* value);
CAPIStatus envoyGoTcpUpstreamDrainBuffer(void* s, uint64_t buffer, uint64_t length);
CAPIStatus envoyGoTcpUpstreamSetBufferHelper(void* s, uint64_t buffer, void* data, int length, bufferAction action);
CAPIStatus envoyGoTcpUpstreamGetStringValue(void* r, int id, uint64_t* value_data, int* value_len);
void envoyGoTcpUpstreamFinalize(void* r, int reason);
void envoyGoConfigTcpUpstreamFinalize(void* c);

#ifdef __cplusplus
} // extern "C"
#endif
22 changes: 22 additions & 0 deletions contrib/golang/common/go/api/capi.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ type NetworkCAPI interface {
UpstreamInfo(f unsafe.Pointer, infoType int) string
}

type TcpUpstreamCAPI interface {
// UpstreamConnEnableHalfClose upstream conn EnableHalfClose
UpstreamConnEnableHalfClose(f unsafe.Pointer, enableHalfClose int)

HttpGetHeader(s unsafe.Pointer, key string) string
HttpCopyHeaders(s unsafe.Pointer, num uint64, bytes uint64) map[string][]string
GetBuffer(s unsafe.Pointer, bufferPtr uint64, length uint64) []byte
DrainBuffer(s unsafe.Pointer, bufferPtr uint64, length uint64)
SetBufferHelper(s unsafe.Pointer, bufferPtr uint64, value string, action BufferAction)
SetBytesBufferHelper(s unsafe.Pointer, bufferPtr uint64, value []byte, action BufferAction)
GetStringValue(r unsafe.Pointer, id int) (string, bool)

Finalize(r unsafe.Pointer, reason int)

// /* These APIs are related to config, use the pointer of config. */
ConfigFinalize(c unsafe.Pointer)

/* These APIs have nothing to do with request */
Log(level LogType, message string)
LogLevel() LogType
}

type CommonCAPI interface {
Log(level LogType, message string)
LogLevel() LogType
Expand Down
45 changes: 45 additions & 0 deletions contrib/golang/common/go/api/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ type (
EmptyDownstreamFilter struct{}
// EmptyUpstreamFilter provides the no-op implementation of the UpstreamFilter interface
EmptyUpstreamFilter struct{}
// EmptyTcpUpstreamFilter provides the no-op implementation of the EmptyTcpUpstreamFilter interface
EmptyTcpUpstreamFilter struct{}

PassThroughTcpUpstream struct {
EmptyTcpUpstreamFilter
}
)

// request
Expand Down Expand Up @@ -255,6 +261,12 @@ func (*EmptyUpstreamFilter) OnData(buffer []byte, endOfStream bool) FilterStatus
func (*EmptyUpstreamFilter) OnEvent(event ConnectionEvent) {
}

type TcpUpstreamCallbackHandler interface {
FilterCallbackHandler
duxin40 marked this conversation as resolved.
Show resolved Hide resolved
// EnableHalfClose only for upstream connection
EnableHalfClose(enabled bool)
}

type ConnectionCallback interface {
// StreamInfo returns the stream info of the connection
StreamInfo() StreamInfo
Expand Down Expand Up @@ -330,3 +342,36 @@ type GaugeMetric interface {
// TODO
type HistogramMetric interface {
}

type TcpUpstreamFilter interface {
EncodeHeaders(headerMap RequestHeaderMap, endOfStream bool)
// Invoked when data is delivered from the upstream connection.
EncodeData(buffer BufferInstance, endOfStream bool) (EndStream bool)
// Called when data is read on from tcp upstream.
OnUpstreamData(buffer BufferInstance, endOfStream bool) UpstreamDataStatus
// destroy filter
OnDestroy(DestroyReason)
}

func (*EmptyTcpUpstreamFilter) EncodeHeaders(headerMap RequestHeaderMap, endOfStream bool) {
}

func (*EmptyTcpUpstreamFilter) EncodeData(buffer BufferInstance, endOfStream bool) bool {
return true
}

func (*EmptyTcpUpstreamFilter) OnUpstreamData(buffer BufferInstance, endOfStream bool) UpstreamDataStatus {
return UpstreamDataFinish
}

func (*EmptyTcpUpstreamFilter) OnDestroy(DestroyReason) {
}

type TcpUpstreamFactory func(config interface{}, callbacks TcpUpstreamCallbackHandler) TcpUpstreamFilter

type TcpUpstreamConfigParser interface {
// Parse the proto message to any Go value, and return error to reject the config.
// This is called when Envoy receives the config from the control plane.
// Also, you can define Metrics through the callbacks, and the callbacks will be nil when parsing the route config.
Parse(any *anypb.Any, callbacks ConfigCallbackHandler) (interface{}, error)
}
60 changes: 60 additions & 0 deletions contrib/golang/common/go/api/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,63 @@ var (
)

// *************** errors end **************//

// Status codes returned by tcp upstream that can deal with data.
type UpstreamDataStatus int

const (
// Continue to deal with further data.
UpstreamDataContinue UpstreamDataStatus = 0
// Finish dealing with data.
UpstreamDataFinish UpstreamDataStatus = 1
// Failure when dealing with data.
UpstreamDataFailure UpstreamDataStatus = 2
)

func (s UpstreamDataStatus) String() string {
switch s {
case UpstreamDataContinue:
return "Continue"
case UpstreamDataFinish:
return "Finish"
case UpstreamDataFailure:
return "Failure"
}
return "unknown"
}

// Info types called by tcp upstream that can get the corresponding info from c++ side.
type TcpUpstreamInfoType int

const (
TcpUpstreamInfoRouterName TcpUpstreamInfoType = 0
TcpUpstreamInfoClusterName TcpUpstreamInfoType = 1
)

func (t TcpUpstreamInfoType) String() string {
switch t {
case TcpUpstreamInfoRouterName:
return "TcpUpstreamInfoRouterName"
case TcpUpstreamInfoClusterName:
return "TcpUpstreamInfoClusterName"
}
return "unknown"
}

type EndStreamType int

const (
NotEndStream EndStreamType = 0
EndStream EndStreamType = 1
)

func (t EndStreamType) String() string {
switch t {
case NotEndStream:
return "NotEndStream"
case EndStream:
return "EndStream"
}
return "unknown"
}

Loading