jasondeng1997 commented on code in PR #2100:
URL: https://github.com/apache/dubbo-go/pull/2100#discussion_r1016108770
##########
registry/polaris/registry.go:
##########
@@ -159,21 +158,43 @@ func (pr *polarisRegistry) Subscribe(url *common.URL,
notifyListener registry.No
for {
listener, err := NewPolarisListener(url)
+
if err != nil {
logger.Warnf("getListener() = err:%v",
perrors.WithStack(err))
<-time.After(time.Duration(RegistryConnDelay) *
time.Second)
continue
}
+ serviceName := getServiceName(url)
+ watcher, err := pr.createPolarisWatcher(serviceName)
+ if err != nil {
+ return err
+ }
- watcher, err := newPolarisWatcher(&newParam, newConsumer)
+ watcher.AddSubscriber(func(et remoting.EventType, instances
[]model.Instance) {
+ dubboInstances := make([]registry.ServiceInstance, 0,
len(instances))
+ for _, instance := range instances {
+ dubboInstances = append(dubboInstances,
®istry.DefaultServiceInstance{
+ ID: instance.GetId(),
+ ServiceName: instance.GetService(),
+ Host: instance.GetHost(),
+ Port: int(instance.GetPort()),
+ Enable: !instance.IsIsolated(),
+ Healthy: instance.IsHealthy(),
+ Metadata: instance.GetMetadata(),
+ GroupName:
instance.GetMetadata()[constant.PolarisDubboGroup],
+ })
+ }
+ registry.NewServiceInstancesChangedEvent(serviceName,
dubboInstances)
+ listener.Next()
Review Comment:
这个事件需要传递给listener吗,这个是一个notify事件,执行通知就行了
--
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]