1kasa commented on code in PR #2862:
URL: https://github.com/apache/dubbo-go/pull/2862#discussion_r2077292766


##########
config/root_config.go:
##########
@@ -367,3 +372,27 @@ func (rc *RootConfig) Process(event 
*config_center.ConfigChangeEvent) {
        // dynamically update metric
        rc.Metrics.DynamicUpdateProperties(updateRootConfig.Metrics)
 }
+
+func validateRegistryAddresses(registries map[string]*RegistryConfig) error {
+       cacheKeyMap := make(map[string]string)
+
+       for id, reg := range registries {
+               address := reg.Address
+               namespace := reg.Namespace
+
+               cacheKey := address
+               if namespace != "" {
+                       cacheKey = cacheKey + "?" + constant.NacosNamespaceID + 
"=" + namespace
+               }
+
+               if existingID, exists := cacheKeyMap[cacheKey]; exists {
+                       err := fmt.Errorf("duplicate registry address: [%s] 
used by both [%s] and [%s]", cacheKey, existingID, id)
+                       logger.Error(err)

Review Comment:
   
因为这里需要让调用者感知并处理错误,所以这里进行了定义并捕获err,如果只是单纯的打印可以直接使用logger.Errorf()来避免引入,但是这个函数是用来check的本身是不会有err定义并中断



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