marsevilspirit commented on code in PR #2868:
URL: https://github.com/apache/dubbo-go/pull/2868#discussion_r2084613621
##########
common/constant/default.go:
##########
@@ -32,21 +32,21 @@ const (
)
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 int64 = 100
Review Comment:
这里不要改成int64,我想不到为什么要改成int64,weight明显不需要这么大的数
##########
registry/nacos/service_discovery.go:
##########
@@ -315,13 +312,12 @@ func (n *nacosServiceDiscovery)
toRegisterInstance(instance registry.ServiceInst
metadata = make(map[string]string, 1)
}
- weightStr :=
n.registryURL.GetParam(constant.RegistryKey+"."+constant.WeightKey, "1.0")
- weight, err := strconv.ParseFloat(weightStr, 64)
- if err != nil || weight <= constant.MinNacosWeight {
- logger.Warnf("Invalid weight value %q, using default 1.0. err:
%v", weightStr, err)
+ weight := instance.GetWeight()
Review Comment:
这行代码并不优雅
##########
registry/nacos/service_discovery.go:
##########
@@ -66,9 +65,6 @@ type nacosServiceDiscovery struct {
// cache registry instances
registryInstances []registry.ServiceInstance
- // registryURL stores the URL used for registration, used to fetch
dynamic config like weight
Review Comment:
为什么删除registryURL?我认为这个很好,你可以将weight的配置放在URL中
##########
registry/service_instance.go:
##########
@@ -131,6 +133,17 @@ func (d *DefaultServiceInstance) IsHealthy() bool {
return d.Healthy
}
+func (d *DefaultServiceInstance) GetWeight() int64 {
Review Comment:
不要这样传递配置,放在URL里
##########
metadata/info/metadata_info.go:
##########
@@ -212,6 +212,7 @@ type ServiceInfo struct {
Port int `json:"port,omitempty" hessian:"port"`
Path string `json:"path,omitempty" hessian:"path"`
Params map[string]string `json:"params,omitempty" hessian:"params"`
+ Weight int64 `json:"weight,omitempty" hessian:"weight"`
Review Comment:
weight放进ServiceInfo的结构体里?这并不符合人类的逻辑,weight和Service没有关系
--
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]