You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by la...@apache.org on 2021/12/06 14:44:29 UTC
[dubbo-go] 01/01: Ftr: add triple max size configuration
This is an automated email from the ASF dual-hosted git repository.
laurence pushed a commit to branch ftr/triple-max-size
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
commit 29e59f64d2ae48282d61421da96e96b6ff2c8cba
Author: LaurenceLiZhixin <38...@qq.com>
AuthorDate: Mon Dec 6 22:44:14 2021 +0800
Ftr: add triple max size configuration
---
common/constant/key.go | 8 ++++++--
common/rpc_service.go | 7 ++++---
go.mod | 2 +-
go.sum | 4 ++--
protocol/dubbo3/dubbo3_invoker.go | 11 ++++++++++-
protocol/dubbo3/dubbo3_protocol.go | 12 ++++++++++++
6 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/common/constant/key.go b/common/constant/key.go
index 4c55383..79d91af 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -52,8 +52,12 @@ const (
CommaSeparator = ","
SslEnabledKey = "ssl-enabled"
// ParamsTypeKey key used in pass through invoker factory, to define param type
- ParamsTypeKey = "parameter-type-names"
- MetadataTypeKey = "metadata-type"
+ ParamsTypeKey = "parameter-type-names"
+ MetadataTypeKey = "metadata-type"
+ MaxCallSendMsgSize = "max-call-send-msg-size"
+ MaxServerSendMsgSize = "max-server-send-msg-size"
+ MaxCallRecvMsgSize = "max-call-recv-msg-size"
+ MaxServerRecvMsgSize = "max-server-recv-msg-size"
)
const (
diff --git a/common/rpc_service.go b/common/rpc_service.go
index a24a778..dedac04 100644
--- a/common/rpc_service.go
+++ b/common/rpc_service.go
@@ -382,9 +382,10 @@ func suiteMethod(method reflect.Method) *MethodType {
argsType []reflect.Type
)
- // Reference is used to define service reference, and method with prefix 'XXX' is generated by triple pb tool
- // They should not to be exported
- if mname == "Reference" || strings.HasPrefix(mname, "XXX") {
+ // Reference is used to define service reference, and method with prefix 'XXX' is generated by triple pb tool.
+ // SetGRPCServer is used for pb reflection.
+ // They should not to be checked.
+ if mname == "Reference" || mname == "SetGRPCServer" || strings.HasPrefix(mname, "XXX") {
return nil
}
diff --git a/go.mod b/go.mod
index 8319c96..b81a578 100644
--- a/go.mod
+++ b/go.mod
@@ -14,7 +14,7 @@ require (
github.com/dubbogo/go-zookeeper v1.0.3
github.com/dubbogo/gost v1.11.20-0.20211116110728-26777ca61b4a
github.com/dubbogo/grpc-go v1.42.6-triple
- github.com/dubbogo/triple v1.1.6-0.20211119123944-4ad68a0d048e
+ github.com/dubbogo/triple v1.1.6
github.com/emicklei/go-restful/v3 v3.7.2
github.com/fsnotify/fsnotify v1.5.1
github.com/ghodss/yaml v1.0.0
diff --git a/go.sum b/go.sum
index 0abe072..86df222 100644
--- a/go.sum
+++ b/go.sum
@@ -192,8 +192,8 @@ github.com/dubbogo/grpc-go v1.42.6-triple/go.mod h1:F1T9hnUvYGW4JLK1QNriavpOkhus
github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU=
github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc=
github.com/dubbogo/triple v1.0.9/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw=
-github.com/dubbogo/triple v1.1.6-0.20211119123944-4ad68a0d048e h1:GJDV0dOaKwSP/4i8eaDNJ/FpH3sW9czArA0MGj4BZ8Q=
-github.com/dubbogo/triple v1.1.6-0.20211119123944-4ad68a0d048e/go.mod h1:5lGslNo9Tq8KR8+tSSSJkhypNaREYZCKCk0Owx40Cx4=
+github.com/dubbogo/triple v1.1.6 h1:+OxaOm++o/ubuZw4TI5xDpswpC3DnwIGxeYO9m+oVAM=
+github.com/dubbogo/triple v1.1.6/go.mod h1:5lGslNo9Tq8KR8+tSSSJkhypNaREYZCKCk0Owx40Cx4=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go
index 88af74d..7b15838 100644
--- a/protocol/dubbo3/dubbo3_invoker.go
+++ b/protocol/dubbo3/dubbo3_invoker.go
@@ -69,7 +69,6 @@ func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) {
dubboSerializaerType := url.GetParam(constant.SerializationKey, constant.ProtobufSerialization)
triCodecType := tripleConstant.CodecType(dubboSerializaerType)
// new triple client
-
opts := []triConfig.OptionFunction{
triConfig.WithClientTimeout(uint32(timeout.Seconds())),
triConfig.WithCodecType(triCodecType),
@@ -78,6 +77,16 @@ func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) {
triConfig.WithHeaderGroup(url.GetParam(constant.GroupKey, "")),
triConfig.WithLogger(logger.GetLogger()),
}
+ if maxCall := url.GetParam(constant.MaxCallRecvMsgSize, ""); maxCall != "" {
+ if size, err := strconv.Atoi(maxCall); err == nil && size != 0 {
+ opts = append(opts, triConfig.WithGRPCMaxCallRecvMessageSize(size))
+ }
+ }
+ if maxCall := url.GetParam(constant.MaxCallSendMsgSize, ""); maxCall != "" {
+ if size, err := strconv.Atoi(maxCall); err == nil && size != 0 {
+ opts = append(opts, triConfig.WithGRPCMaxCallSendMessageSize(size))
+ }
+ }
tracingKey := url.GetParam(constant.TracingConfigKey, "")
if tracingKey != "" {
diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go
index 78f5308..6ff8281 100644
--- a/protocol/dubbo3/dubbo3_protocol.go
+++ b/protocol/dubbo3/dubbo3_protocol.go
@@ -21,6 +21,7 @@ import (
"context"
"fmt"
"reflect"
+ "strconv"
"sync"
)
@@ -234,6 +235,17 @@ func (dp *DubboProtocol) openServer(url *common.URL, tripleCodecType tripleConst
}
}
+ if maxCall := url.GetParam(constant.MaxServerRecvMsgSize, ""); maxCall != "" {
+ if size, err := strconv.Atoi(maxCall); err == nil && size != 0 {
+ opts = append(opts, triConfig.WithGRPCMaxServerRecvMessageSize(size))
+ }
+ }
+ if maxCall := url.GetParam(constant.MaxServerSendMsgSize, ""); maxCall != "" {
+ if size, err := strconv.Atoi(maxCall); err == nil && size != 0 {
+ opts = append(opts, triConfig.WithGRPCMaxServerSendMessageSize(size))
+ }
+ }
+
triOption := triConfig.NewTripleOption(opts...)
_, ok = dp.ExporterMap().Load(url.ServiceKey())