Skip to content

Commit

Permalink
Merge a0c39c2 into 55a0639
Browse files Browse the repository at this point in the history
  • Loading branch information
FoghostCn authored Apr 3, 2024
2 parents 55a0639 + a0c39c2 commit e5e3b00
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions metadata/service/local/metadata_service_proxy_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func createProxy(ins registry.ServiceInstance) service.MetadataService {
u := urls[0]
p := extension.GetProtocol(u.Protocol)
invoker := p.Refer(u)
if invoker == nil { // can't connect instance
return nil
}
return &MetadataServiceProxy{
Invoker: invoker,
}
Expand Down
7 changes: 5 additions & 2 deletions registry/servicediscovery/service_discovery_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ func (s *ServiceDiscoveryRegistry) Subscribe(url *common.URL, notify registry.No
}
logger.Infof("Find initial mapping applications %q for service %s.", services, url.ServiceKey())
// first notify
mappingListener.OnEvent(registry.NewServiceMappingChangedEvent(url.ServiceKey(), services))
err = mappingListener.OnEvent(registry.NewServiceMappingChangedEvent(url.ServiceKey(), services))
if err != nil {
logger.Errorf("[ServiceDiscoveryRegistry] ServiceInstancesChangedListenerImpl handle error:%v", err)
}
return nil
}

Expand All @@ -246,7 +249,7 @@ func (s *ServiceDiscoveryRegistry) SubscribeURL(url *common.URL, notify registry
Instances: instances,
})
if err != nil {
logger.Warnf("[ServiceDiscoveryRegistry] ServiceInstancesChangedListenerImpl handle error:%v", err)
logger.Errorf("[ServiceDiscoveryRegistry] ServiceInstancesChangedListenerImpl handle error:%v", err)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package servicediscovery

import (
"encoding/gob"
"errors"
"reflect"
"sync"
"time"
Expand Down Expand Up @@ -253,6 +254,9 @@ func GetMetadataInfo(app string, instance registry.ServiceInstance, revision str
var err error
proxyFactory := extension.GetMetadataServiceProxyFactory(constant.DefaultKey)
metadataService := proxyFactory.GetProxy(instance)
if metadataService == nil {
return nil, errors.New("get remote metadata error please check instance " + instance.GetHost() + " is alive")
}
defer destroyInvoker(metadataService)
metadataInfo, err = metadataService.GetMetadataInfo(revision)
if err != nil {
Expand Down

0 comments on commit e5e3b00

Please sign in to comment.