You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/04/04 09:20:08 UTC

[GitHub] [dubbo-go-pixiu] AlexStocks commented on a diff in pull request #389: Bugfix nacos registry bug

AlexStocks commented on code in PR #389:
URL: https://github.com/apache/dubbo-go-pixiu/pull/389#discussion_r841531860


##########
pkg/adapter/dubboregistry/registry/nacos/interface_listener.go:
##########
@@ -146,53 +151,74 @@ func fromServiceFullKey(fullKey string) *serviceInfo {
 }
 
 func (z *nacosIntfListener) updateServiceList(serviceList []string) error {
-	// todo lock all svc listener
+	// add new service info and watch
+
+	newServiceMap := make(map[string]bool)
 
-	allSvcListener := z.reg.GetAllSvcListener()
-	subscribedServiceKeysMap := make(map[string]bool)
-	for k := range allSvcListener {
-		subscribedServiceKeysMap[k] = true
-	}
-	serviceNeedUpdate := make([]*serviceInfo, 0)
 	for _, v := range serviceList {
 		svcInfo := fromServiceFullKey(v)
 		if svcInfo == nil {
 			// invalid nacos dubbo service key
 			continue
 		}
 		key := svcInfo.String()
-		if _, ok := allSvcListener[key]; !ok {
-			serviceNeedUpdate = append(serviceNeedUpdate, svcInfo)
-		} else {
-			delete(subscribedServiceKeysMap, key)
+		newServiceMap[key] = true
+		if _, ok := z.serviceInfoMap[key]; !ok {
+
+			url, _ := dubboCommon.NewURL("mock://localhost:8848")
+			url.SetParam(constant.InterfaceKey, svcInfo.interfaceName)
+			url.SetParam(constant.GroupKey, svcInfo.group)
+			url.SetParam(constant.VersionKey, svcInfo.version)
+			l := newNacosSrvListener(url, z.client, z.adapterListener)
+			l.wg.Add(1)
+
+			svcInfo.listener = l
+			z.serviceInfoMap[key] = svcInfo
+
+			go func(v *serviceInfo) {
+				defer l.wg.Done()

Review Comment:
   这个 wg 在哪里 wait 啊?



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org