Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxuwan committed Nov 8, 2020
1 parent 3c621f0 commit 2346339
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
10 changes: 0 additions & 10 deletions registry/zookeeper/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
type RegistryDataListener struct {
subscribed map[string]config_center.ConfigurationListener
mutex sync.Mutex
closed bool
}

// NewRegistryDataListener constructs a new RegistryDataListener
Expand All @@ -50,17 +49,11 @@ func NewRegistryDataListener() *RegistryDataListener {

// SubscribeURL is used to set a watch listener for url
func (l *RegistryDataListener) SubscribeURL(url *common.URL, listener config_center.ConfigurationListener) {
if l.closed {
return
}
l.subscribed[url.ServiceKey()] = listener
}

// UnSubscribeURL is used to set a watch listener for url
func (l *RegistryDataListener) UnSubscribeURL(url *common.URL) config_center.ConfigurationListener {
if l.closed {
return nil
}
listener := l.subscribed[url.ServiceKey()]
delete(l.subscribed, url.ServiceKey())
return listener
Expand All @@ -82,9 +75,6 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool {
}
l.mutex.Lock()
defer l.mutex.Unlock()
if l.closed {
return false
}
for serviceKey, listener := range l.subscribed {
if serviceURL.ServiceKey() == serviceKey {
listener.Process(
Expand Down
5 changes: 1 addition & 4 deletions registry/zookeeper/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,17 @@ func (r *zkRegistry) getCloseListener(conf *common.URL) (*RegistryConfigurationL

var zkListener *RegistryConfigurationListener
r.dataListener.mutex.Lock()
defer r.dataListener.mutex.Unlock()
configurationListener := r.dataListener.subscribed[conf.ServiceKey()]
if configurationListener != nil {

zkListener, _ := configurationListener.(*RegistryConfigurationListener)
if zkListener != nil {
if zkListener.isClosed {
return nil, perrors.New("configListener already been closed")
}
}
}

zkListener = r.dataListener.UnSubscribeURL(conf).(*RegistryConfigurationListener)
r.dataListener.mutex.Unlock()

if r.listener == nil {
return nil, perrors.New("listener is null can not close.")
}
Expand Down

0 comments on commit 2346339

Please sign in to comment.