diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 54f0acd8433f8eb1bbefb36403248056f70177de..7ffc702248bfe26f82105be6a7220b86d3c3ae51 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -38,6 +38,7 @@ import ( "github.com/apache/dubbo-go/protocol" "github.com/apache/dubbo-go/protocol/protocolwrapper" "github.com/apache/dubbo-go/registry" + "github.com/apache/dubbo-go/remoting" ) const ( @@ -123,20 +124,19 @@ func (dir *registryDirectory) refreshInvokers(res *registry.ServiceEvent) { url = nil //TODO: router } + switch res.Action { + case remoting.EventTypeAdd, remoting.EventTypeUpdate: + //dir.cacheService.EventTypeAdd(res.Path, dir.serviceTTL) + dir.cacheInvoker(url) + case remoting.EventTypeDel: + //dir.cacheService.EventTypeDel(res.Path, dir.serviceTTL) + dir.uncacheInvoker(url) + logger.Infof("selector delete service url{%s}", res.Service) + default: + return + } } - // - //switch res.Action { - //case remoting.EventTypeAdd: - // //dir.cacheService.EventTypeAdd(res.Path, dir.serviceTTL) - // dir.cacheInvoker(&res.Service) - //case remoting.EventTypeDel: - // //dir.cacheService.EventTypeDel(res.Path, dir.serviceTTL) - // dir.uncacheInvoker(&res.Service) - // logger.Infof("selector delete service url{%s}", res.Service) - //default: - // return - //} - dir.cacheInvoker(url) + newInvokers := dir.toGroupInvokers() dir.listenerLock.Lock() defer dir.listenerLock.Unlock()