in protocol/dubbo3/dubbo3_invoker.go [69:140]
func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) {
rt := config.GetConsumerConfig().RequestTimeout
timeout := url.GetParamDuration(constant.TimeoutKey, rt)
// for triple pb serialization. The bean name from provider is the provider reference key,
// which can't locate the target consumer stub, so we use interface key..
interfaceKey := url.GetParam(constant.InterfaceKey, "")
consumerService := config.GetConsumerServiceByInterfaceName(interfaceKey)
dubboSerializerType := url.GetParam(constant.SerializationKey, constant.ProtobufSerialization)
triCodecType := tripleConstant.CodecType(dubboSerializerType)
// new triple client
opts := []triConfig.OptionFunction{
triConfig.WithClientTimeout(timeout),
triConfig.WithCodecType(triCodecType),
triConfig.WithLocation(url.Location),
triConfig.WithHeaderAppVersion(url.GetParam(constant.AppVersionKey, "")),
triConfig.WithHeaderGroup(url.GetParam(constant.GroupKey, "")),
triConfig.WithLogger(logger.GetLogger()),
}
maxCallRecvMsgSize := constant.DefaultMaxCallRecvMsgSize
if maxCall, err := humanize.ParseBytes(url.GetParam(constant.MaxCallRecvMsgSize, "")); err == nil && maxCall != 0 {
maxCallRecvMsgSize = int(maxCall)
}
maxCallSendMsgSize := constant.DefaultMaxCallSendMsgSize
if maxCall, err := humanize.ParseBytes(url.GetParam(constant.MaxCallSendMsgSize, "")); err == nil && maxCall != 0 {
maxCallSendMsgSize = int(maxCall)
}
opts = append(opts, triConfig.WithGRPCMaxCallRecvMessageSize(maxCallRecvMsgSize))
opts = append(opts, triConfig.WithGRPCMaxCallSendMessageSize(maxCallSendMsgSize))
tracingKey := url.GetParam(constant.TracingConfigKey, "")
if tracingKey != "" {
tracingConfig := config.GetTracingConfig(tracingKey)
if tracingConfig != nil {
if tracingConfig.Name == "jaeger" {
if tracingConfig.ServiceName == "" {
tracingConfig.ServiceName = config.GetApplicationConfig().Name
}
opts = append(opts, triConfig.WithJaegerConfig(
tracingConfig.Address,
tracingConfig.ServiceName,
*tracingConfig.UseAgent,
))
} else {
logger.Warnf("unsupported tracing name %s, now triple only support jaeger", tracingConfig.Name)
}
}
}
triOption := triConfig.NewTripleOption(opts...)
tlsConfig := config.GetRootConfig().TLSConfig
if tlsConfig != nil {
triOption.TLSCertFile = tlsConfig.TLSCertFile
triOption.TLSKeyFile = tlsConfig.TLSKeyFile
triOption.CACertFile = tlsConfig.CACertFile
triOption.TLSServerName = tlsConfig.TLSServerName
logger.Infof("Triple Client initialized the TLSConfig configuration")
}
client, err := triple.NewTripleClient(consumerService, triOption)
if err != nil {
return nil, err
}
return &DubboInvoker{
BaseInvoker: *protocol.NewBaseInvoker(url),
client: client,
timeout: timeout,
clientGuard: &sync.RWMutex{},
}, nil
}