Skip to content
Snippets Groups Projects
Commit be426b6a authored by 邹毅贤's avatar 邹毅贤
Browse files

fix review problems

parent 93351409
Branches
Tags
No related merge requests found
...@@ -240,7 +240,7 @@ func (r *BaseRegistry) unregister(c common.URL) error { ...@@ -240,7 +240,7 @@ func (r *BaseRegistry) unregister(c common.URL) error {
return r.processURL(c, r.facadeBasedRegistry.DoUnregister, nil) return r.processURL(c, r.facadeBasedRegistry.DoUnregister, nil)
} }
func (r *BaseRegistry) processURL(c common.URL, f func(string, string) error, createPathFunc func(dubboPath string) error) error { func (r *BaseRegistry) processURL(c common.URL, f func(string, string) error, cpf createPathFunc) error {
if f == nil { if f == nil {
panic(" Must provide a `function(string, string) error` to process URL. ") panic(" Must provide a `function(string, string) error` to process URL. ")
} }
...@@ -268,9 +268,9 @@ func (r *BaseRegistry) processURL(c common.URL, f func(string, string) error, cr ...@@ -268,9 +268,9 @@ func (r *BaseRegistry) processURL(c common.URL, f func(string, string) error, cr
switch role { switch role {
case common.PROVIDER: case common.PROVIDER:
dubboPath, rawURL, err = r.providerRegistry(c, params, createPathFunc) dubboPath, rawURL, err = r.providerRegistry(c, params, cpf)
case common.CONSUMER: case common.CONSUMER:
dubboPath, rawURL, err = r.consumerRegistry(c, params, createPathFunc) dubboPath, rawURL, err = r.consumerRegistry(c, params, cpf)
default: default:
return perrors.Errorf("@c{%v} type is not referencer or provider", c) return perrors.Errorf("@c{%v} type is not referencer or provider", c)
} }
...@@ -292,7 +292,7 @@ func (r *BaseRegistry) createPath(dubboPath string) error { ...@@ -292,7 +292,7 @@ func (r *BaseRegistry) createPath(dubboPath string) error {
} }
// providerRegistry for provider role do // providerRegistry for provider role do
func (r *BaseRegistry) providerRegistry(c common.URL, params url.Values, createPathFunc func(dubboPath string) error) (string, string, error) { func (r *BaseRegistry) providerRegistry(c common.URL, params url.Values, f createPathFunc) (string, string, error) {
var ( var (
dubboPath string dubboPath string
rawURL string rawURL string
...@@ -302,8 +302,8 @@ func (r *BaseRegistry) providerRegistry(c common.URL, params url.Values, createP ...@@ -302,8 +302,8 @@ func (r *BaseRegistry) providerRegistry(c common.URL, params url.Values, createP
return "", "", perrors.Errorf("conf{Path:%s, Methods:%s}", c.Path, c.Methods) return "", "", perrors.Errorf("conf{Path:%s, Methods:%s}", c.Path, c.Methods)
} }
dubboPath = fmt.Sprintf("/dubbo/%s/%s", r.service(c), common.DubboNodes[common.PROVIDER]) dubboPath = fmt.Sprintf("/dubbo/%s/%s", r.service(c), common.DubboNodes[common.PROVIDER])
if createPathFunc != nil { if f != nil {
err = createPathFunc(dubboPath) err = f(dubboPath)
} }
if err != nil { if err != nil {
logger.Errorf("facadeBasedRegistry.CreatePath(path{%s}) = error{%#v}", dubboPath, perrors.WithStack(err)) logger.Errorf("facadeBasedRegistry.CreatePath(path{%s}) = error{%#v}", dubboPath, perrors.WithStack(err))
...@@ -384,7 +384,7 @@ func (r *BaseRegistry) Subscribe(url *common.URL, notifyListener NotifyListener) ...@@ -384,7 +384,7 @@ func (r *BaseRegistry) Subscribe(url *common.URL, notifyListener NotifyListener)
n++ n++
if !r.IsAvailable() { if !r.IsAvailable() {
logger.Warnf("event listener game over.") logger.Warnf("event listener game over.")
return perrors.New("nacosRegistry is not available.") return perrors.New("BaseRegistry is not available.")
} }
listener, err := r.facadeBasedRegistry.DoSubscribe(url) listener, err := r.facadeBasedRegistry.DoSubscribe(url)
...@@ -417,17 +417,16 @@ func (r *BaseRegistry) Subscribe(url *common.URL, notifyListener NotifyListener) ...@@ -417,17 +417,16 @@ func (r *BaseRegistry) Subscribe(url *common.URL, notifyListener NotifyListener)
func (r *BaseRegistry) UnSubscribe(url *common.URL, notifyListener NotifyListener) error { func (r *BaseRegistry) UnSubscribe(url *common.URL, notifyListener NotifyListener) error {
if !r.IsAvailable() { if !r.IsAvailable() {
logger.Warnf("event listener game over.") logger.Warnf("event listener game over.")
return nil return perrors.New("BaseRegistry is not available.")
} }
listener, err := r.facadeBasedRegistry.DoUnsubscribe(url) listener, err := r.facadeBasedRegistry.DoUnsubscribe(url)
if err != nil { if err != nil {
if !r.IsAvailable() { if !r.IsAvailable() {
logger.Warnf("event listener game over.") logger.Warnf("event listener game over.")
return nil return perrors.New("BaseRegistry is not available.")
} }
logger.Warnf("getListener() = err:%v", perrors.WithStack(err)) logger.Warnf("getListener() = err:%v", perrors.WithStack(err))
time.Sleep(time.Duration(RegistryConnDelay) * time.Second)
return perrors.WithStack(err) return perrors.WithStack(err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment