No-SilverBullet commented on code in PR #2843:
URL: https://github.com/apache/dubbo-go/pull/2843#discussion_r2051719229


##########
registry/nacos/registry.go:
##########
@@ -99,11 +99,22 @@ func createRegisterParam(url *common.URL, serviceName 
string, groupName string)
        params[constant.MethodsKey] = strings.Join(url.Methods, ",")
        common.HandleRegisterIPAndPort(url)
        port, _ := strconv.Atoi(url.Port)
+
+       weightStr := url.GetParam(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 = constant.DefaultNacosWeight
+       } else if weight > constant.MaxNacosWeight {

Review Comment:
   can we extract the logic of processing weight into a separate function? it 
seems this logic has both been used in registry.go and service_discovery.go



-- 
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]

Reply via email to