Skip to content

Commit

Permalink
Ftr: add triple max size configuration (#1654)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceLiZhixin authored Dec 7, 2021
1 parent 55e9fdf commit 0ff42ce
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
8 changes: 6 additions & 2 deletions common/constant/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
7 changes: 4 additions & 3 deletions common/rpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
11 changes: 10 additions & 1 deletion protocol/dubbo3/dubbo3_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 != "" {
Expand Down
12 changes: 12 additions & 0 deletions protocol/dubbo3/dubbo3_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"fmt"
"reflect"
"strconv"
"sync"
)

Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 0ff42ce

Please sign in to comment.