CAICAIIs commented on code in PR #3178:
URL: https://github.com/apache/dubbo-go/pull/3178#discussion_r2725649359
##########
registry/nacos/registry.go:
##########
@@ -200,15 +202,24 @@ func (nr *nacosRegistry) Subscribe(url *common.URL,
notifyListener registry.Noti
}
func (nr *nacosRegistry) subscribeUntilSuccess(url *common.URL, notifyListener
registry.NotifyListener) {
- // retry forever
- for {
+ bo := backoff.NewExponentialBackOff()
+ bo.InitialInterval = 1 * time.Second
+ bo.MaxInterval = 30 * time.Second
+ bo.MaxElapsedTime = 0 // never timeout, retry forever
+
+ operation := func() error {
if !nr.IsAvailable() {
- return
- }
- err := nr.subscribe(getSubscribeName(url), notifyListener)
- if err == nil {
- return
+ return backoff.Permanent(perrors.New("registry
unavailable"))
}
+ return nr.subscribe(getSubscribeName(url), notifyListener)
+ }
+
+ notify := func(err error, duration time.Duration) {
+ logger.Warnf("[Nacos Registry] subscribe failed, retry after
%v: %v", duration, err)
+ }
+
Review Comment:
感谢cr,问题指出的很精确
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]