Skip to content
Snippets Groups Projects
Commit 744afb25 authored by flycash's avatar flycash
Browse files

Fix Review

parent f433c063
No related branches found
No related tags found
No related merge requests found
...@@ -263,9 +263,9 @@ func (s *serviceDiscoveryRegistry) Subscribe(url *common.URL, notify registry.No ...@@ -263,9 +263,9 @@ func (s *serviceDiscoveryRegistry) Subscribe(url *common.URL, notify registry.No
} }
s.registerServiceInstancesChangedListener(*url, listener) s.registerServiceInstancesChangedListener(*url, listener)
} }
return nil return nil
} }
func (s *serviceDiscoveryRegistry) registerServiceInstancesChangedListener(url common.URL, listener *registry.ServiceInstancesChangedListener) { func (s *serviceDiscoveryRegistry) registerServiceInstancesChangedListener(url common.URL, listener *registry.ServiceInstancesChangedListener) {
listenerId := listener.ServiceName + ":" + getUrlKey(url) listenerId := listener.ServiceName + ":" + getUrlKey(url)
if !s.subscribedServices.Contains(listenerId) { if !s.subscribedServices.Contains(listenerId) {
...@@ -335,6 +335,7 @@ func (s *serviceDiscoveryRegistry) synthesizeSubscribedURLs(subscribedURL *commo ...@@ -335,6 +335,7 @@ func (s *serviceDiscoveryRegistry) synthesizeSubscribedURLs(subscribedURL *commo
} }
return urls return urls
} }
func shouldSubscribe(url common.URL) bool { func shouldSubscribe(url common.URL) bool {
return !shouldRegister(url) return !shouldRegister(url)
} }
......
...@@ -22,8 +22,6 @@ import ( ...@@ -22,8 +22,6 @@ import (
"path" "path"
"strings" "strings"
"sync" "sync"
"github.com/dubbogo/go-zookeeper/zk"
) )
import ( import (
...@@ -31,6 +29,8 @@ import ( ...@@ -31,6 +29,8 @@ import (
) )
import ( import (
"github.com/dubbogo/go-zookeeper/zk"
"github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/logger" "github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/remoting" "github.com/apache/dubbo-go/remoting"
...@@ -119,14 +119,17 @@ func (sd *ServiceDiscovery) UpdateService(instance *ServiceInstance) error { ...@@ -119,14 +119,17 @@ func (sd *ServiceDiscovery) UpdateService(instance *ServiceInstance) error {
if !ok { if !ok {
return perrors.New("[ServiceDiscovery] services value not entry") return perrors.New("[ServiceDiscovery] services value not entry")
} }
entry.Lock()
defer entry.Unlock()
entry.instance = instance
path := sd.pathForInstance(instance.Name, instance.Id)
data, err := json.Marshal(instance) data, err := json.Marshal(instance)
if err != nil { if err != nil {
return err return err
} }
entry.Lock()
defer entry.Unlock()
entry.instance = instance
path := sd.pathForInstance(instance.Name, instance.Id)
_, err = sd.client.SetContent(path, data, -1) _, err = sd.client.SetContent(path, data, -1)
if err != nil { if err != nil {
return err return err
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment