justxuewei commented on code in PR #1969:
URL: https://github.com/apache/dubbo-go/pull/1969#discussion_r922661815


##########
registry/polaris/core.go:
##########
@@ -86,34 +86,36 @@ func (watcher *PolarisServiceWatcher) startWatch() {
                        Value:      resp.GetAllInstancesResp.Instances,
                        ConfigType: remoting.EventTypeAdd,
                })
-
-               select {
-               case event := <-resp.EventChannel:
-                       eType := event.GetSubScribeEventType()
-                       if eType == api.EventInstance {
-                               insEvent := event.(*model.InstanceEvent)
-                               if insEvent.AddEvent != nil {
-                                       
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
-                                               Value:      
insEvent.AddEvent.Instances,
-                                               ConfigType: 
remoting.EventTypeAdd,
-                                       })
-                               }
-                               if insEvent.UpdateEvent != nil {
-                                       instances := make([]model.Instance, 
len(insEvent.UpdateEvent.UpdateList))
-                                       for i := range 
insEvent.UpdateEvent.UpdateList {
-                                               instances[i] = 
insEvent.UpdateEvent.UpdateList[i].After
+               for {
+                       select {
+                       case event := <-resp.EventChannel:
+                               eType := event.GetSubScribeEventType()
+                               if eType == api.EventInstance {
+                                       insEvent := event.(*model.InstanceEvent)
+                                       if insEvent.AddEvent != nil {
+                                               
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+                                                       Value:      
insEvent.AddEvent.Instances,
+                                                       ConfigType: 
remoting.EventTypeAdd,
+                                               })
+                                       }
+                                       if insEvent.UpdateEvent != nil {
+                                               instances := 
make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
+                                               for i := range 
insEvent.UpdateEvent.UpdateList {
+                                                       instances[i] = 
insEvent.UpdateEvent.UpdateList[i].After
+                                               }
+                                               
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+                                                       Value:      instances,
+                                                       ConfigType: 
remoting.EventTypeUpdate,
+                                               })
+                                       }
+                                       if insEvent.DeleteEvent != nil {
+                                               
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+                                                       Value:      
insEvent.DeleteEvent.Instances,
+                                                       ConfigType: 
remoting.EventTypeDel,
+                                               })

Review Comment:
   I agree with @Mulavar, it seems that there is no place to break the loop, as 
a result, `resp, err := watcher.consumer.WatchService(watcher.subscribeParam)` 
will be executed once.



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