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 2021/09/08 06:39:29 UTC

[GitHub] [dubbo-go] chickenlj commented on a change in pull request #1368: Refactor to remove event dispatcher completely

chickenlj commented on a change in pull request #1368:
URL: https://github.com/apache/dubbo-go/pull/1368#discussion_r704094916



##########
File path: registry/zookeeper/service_discovery.go
##########
@@ -306,7 +310,15 @@ func (zksd *zookeeperServiceDiscovery) DataChange(eventType remoting.Event) bool
 	path = strings.TrimPrefix(path, constant.PATH_SEPARATOR)
 	// get service name in zk path
 	serviceName := strings.Split(path, constant.PATH_SEPARATOR)[0]
-	err := zksd.DispatchEventByServiceName(serviceName)
+
+	var err error
+	instances := zksd.GetInstances(serviceName)
+	for _, lis := range zksd.instanceListenerMap[serviceName].Values() {
+		var instanceListener registry.ServiceInstancesChangedListener
+		instanceListener = lis.(registry.ServiceInstancesChangedListener)

Review comment:
       我认为panic是预期内的,这是运行态非预期内行为,就是要以失败结束,再额外捕获我们做不了什么事情。
   
   这里之所有需要转换,是因为 gxset.HashSet 是个通用的结构,存储了 Interface{}

##########
File path: registry/nacos/service_discovery.go
##########
@@ -240,7 +260,13 @@ func (n *nacosServiceDiscovery) AddListener(listener registry.ServiceInstancesCh
 					})
 				}
 
-				e := n.DispatchEventForInstances(serviceName, instances)
+				var e error
+				for _, lis := range n.instanceListenerMap[serviceName].Values() {
+					var instanceListener registry.ServiceInstancesChangedListener
+					instanceListener = lis.(registry.ServiceInstancesChangedListener)

Review comment:
       我认为panic是预期内的,这是运行态非预期内行为,就是要以失败结束,再额外捕获我们做不了什么事情。
   
   这里之所有需要转换,是因为 gxset.HashSet 是个通用的结构,存储了 Interface{}




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