marsevilspirit commented on code in PR #2909:
URL: https://github.com/apache/dubbo-go/pull/2909#discussion_r2120808673
##########
protocol/dubbo/dubbo_invoker.go:
##########
@@ -56,7 +57,18 @@ type DubboInvoker struct {
// NewDubboInvoker constructor
func NewDubboInvoker(url *common.URL, client *remoting.ExchangeClient)
*DubboInvoker {
+ // TODO: Temporary compatibility with old APIs, can be removed later
rt := config.GetConsumerConfig().RequestTimeout
+ if rt == "" {
+ if consumerConfRaw, ok :=
url.GetAttribute(constant.ConsumerConfigKey); ok {
Review Comment:
There is no need to write it this way; we need to ensure that the global
config has the highest priority.
##########
common/constant/default.go:
##########
@@ -29,24 +29,27 @@ const (
EmptyProtocol = "empty"
RouterProtocol = "router"
TriProtocol = "tri"
+ JsonRpcProtocol = "jsonrpc"
)
const (
- DefaultWeight = 100
- DefaultWarmup = 10 * 60 // in java here is 10*60*1000 because
of System.currentTimeMillis() is measured in milliseconds & in go time.Unix()
is second
- DefaultLoadBalance = "random"
- DefaultRetries = "2"
- DefaultRetriesInt = 2
- DefaultProtocol = "dubbo"
- DefaultRegTimeout = "5s"
- DefaultRegTTL = "15m"
- DefaultCluster = "failover"
- DefaultFailbackTimes = "3"
- DefaultFailbackTimesInt = 3
- DefaultFailbackTasks = 100
- DefaultRestClient = "resty"
- DefaultRestServer = "go-restful"
- DefaultPort = 20000
+ DefaultWeight = 100
+ DefaultWarmup = 10 * 60 // in java here is 10*60*1000
because of System.currentTimeMillis() is measured in milliseconds & in go
time.Unix() is second
+ DefaultLoadBalance = "random"
+ DefaultRetries = "2"
+ DefaultRetriesInt = 2
+ DefaultProtocol = "dubbo"
+ DefaultRegTimeout = "5s"
+ DefaultRegTTL = "15m"
+ DefaultCluster = "failover"
+ DefaultFailbackTimes = "3"
+ DefaultFailbackTimesInt = 3
+ DefaultFailbackTasks = 100
+ DefaultRestClient = "resty"
+ DefaultRestServer = "go-restful"
+ DefaultPort = 20000
+ DefaultRequestTimeoutStr = "3s"
+ DefaultRequestTimeoutDuration = 3 * time.Second
Review Comment:
I don't like this Default.
##########
protocol/dubbo3/dubbo3_invoker.go:
##########
@@ -68,13 +69,32 @@ type DubboInvoker struct {
// NewDubboInvoker constructor
func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) {
+ //TODO: Temporary compatibility with old APIs, can be removed later
Review Comment:
Same as above.
##########
protocol/triple/dubbo3_invoker.go:
##########
@@ -70,6 +71,17 @@ type DubboInvoker struct {
func NewDubbo3Invoker(url *common.URL) (*DubboInvoker, error) {
rt := config.GetConsumerConfig().RequestTimeout
+ if rt == "" {
Review Comment:
Same as above.
##########
protocol/dubbo3/dubbo3_invoker.go:
##########
@@ -68,13 +69,32 @@ type DubboInvoker struct {
// NewDubboInvoker constructor
func NewDubboInvoker(url *common.URL) (*DubboInvoker, error) {
+ //TODO: Temporary compatibility with old APIs, can be removed later
rt := config.GetConsumerConfig().RequestTimeout
+ if rt == "" {
+ if consumerConfRaw, ok :=
url.GetAttribute(constant.ConsumerConfigKey); ok {
+ if consumerConf, ok :=
consumerConfRaw.(*global.ConsumerConfig); ok {
+ rt = consumerConf.RequestTimeout
+ } else {
+ rt = constant.DefaultRequestTimeoutStr
+ logger.Warnf("DUBBO Client initialized the
consumer configuration failed")
+ }
+ }
+ }
+
+ // TODO: If you do not need to be compatible with the old API, you can
directly use url.GetAttribute(constant.ConsumerConfigKey) as the timeout
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..
+ // which can't locate the target consumer stub, so we use interface key.
interfaceKey := url.GetParam(constant.InterfaceKey, "")
+ //TODO: Temporary compatibility with old APIs, can be removed later
consumerService :=
config.GetConsumerServiceByInterfaceName(interfaceKey)
Review Comment:
Same as above.
##########
protocol/jsonrpc/jsonrpc_protocol.go:
##########
@@ -79,7 +80,20 @@ func (jp *JsonrpcProtocol) Export(invoker base.Invoker)
base.Exporter {
// Refer a remote JSON PRC service from registry
func (jp *JsonrpcProtocol) Refer(url *common.URL) base.Invoker {
+ // TODO: Temporary compatibility with old APIs, can be removed later
rtStr := config.GetConsumerConfig().RequestTimeout
+
+ if rtStr == "" {
Review Comment:
Same as above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]