chickenlj commented on a change in pull request #1368:
URL: https://github.com/apache/dubbo-go/pull/1368#discussion_r705870282
##########
File path: registry/nacos/service_discovery.go
##########
@@ -210,8 +211,27 @@ func (n *nacosServiceDiscovery)
GetRequestInstances(serviceNames []string, offse
return res
}
+func (n *nacosServiceDiscovery) registerInstanceListener(listener
registry.ServiceInstancesChangedListener) {
+ for _, t := range listener.GetServiceNames().Values() {
Review comment:
It need to be synchronized.
##########
File path: registry/etcdv3/service_discovery.go
##########
@@ -215,31 +216,19 @@ func (e *etcdV3ServiceDiscovery)
GetRequestInstances(serviceNames []string, offs
// see addServiceInstancesChangedListener in Java
func (e *etcdV3ServiceDiscovery) AddListener(listener
registry.ServiceInstancesChangedListener) error {
for _, t := range listener.GetServiceNames().Values() {
- serviceName := t.(string)
- err := e.registerSreviceWatcher(serviceName)
+ err2 := e.registerServiceInstanceListener(t.(string), listener)
+ if err2 != nil {
+ return err2
+ }
+
+ err := e.registerServiceWatcher(t.(string))
Review comment:
Sure, it's better.
##########
File path: registry/etcdv3/service_discovery.go
##########
@@ -282,7 +287,15 @@ func (e *etcdV3ServiceDiscovery) DataChange(eventType
remoting.Event) bool {
instance.ServiceName = ""
}
- if err := e.DispatchEventByServiceName(instance.ServiceName);
err != nil {
+ // notify instance listener instance change
+ name := instance.ServiceName
+ instances := e.GetInstances(name)
+ for _, lis := range
e.instanceListenerMap[instance.ServiceName].Values() {
Review comment:
All listeners are of the same type need to be guaranteed. Or we need to
change the definition of `instanceListenerMap map[string]*gxset.HashSet` in
here, to avoid the defect of Golang does not support generic.
##########
File path: registry/etcdv3/service_discovery.go
##########
@@ -282,7 +287,15 @@ func (e *etcdV3ServiceDiscovery) DataChange(eventType
remoting.Event) bool {
instance.ServiceName = ""
}
- if err := e.DispatchEventByServiceName(instance.ServiceName);
err != nil {
+ // notify instance listener instance change
+ name := instance.ServiceName
+ instances := e.GetInstances(name)
+ for _, lis := range
e.instanceListenerMap[instance.ServiceName].Values() {
Review comment:
`instanceListenerMap
map[string]map[string][*registry.ServiceInstancesChangedListener]`
or if there's generic support
instanceListenerMap map[string]*gxset.HashSet<string,
*registry.ServiceInstancesChangedListener>
--
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]