chuntaojun commented on code in PR #2100:
URL: https://github.com/apache/dubbo-go/pull/2100#discussion_r1016133333
##########
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:
你先看下 nacos.subscribe 里面做的事情,再看看你这里,你都没有吧 event 传到 listener 里面 chan,你这里 next
不就是死等吗
--
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]