You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/01/04 13:34:13 UTC

[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #973: Fix/consul unreg

AlexStocks commented on a change in pull request #973:
URL: https://github.com/apache/dubbo-go/pull/973#discussion_r549727012



##########
File path: registry/consul/registry.go
##########
@@ -188,25 +193,26 @@ func (r *consulRegistry) IsAvailable() bool {
 
 // Destroy consul registry center
 func (r *consulRegistry) Destroy() {
-	if r.URL != nil {
-		done := make(chan struct{}, 1)
-		go func() {
-			defer func() {
-				if e := recover(); e != nil {
-					logger.Errorf("consulRegistry destroy with panic: %v", e)
-				}
-				done <- struct{}{}
-			}()
-			if err := r.UnRegister(r.URL); err != nil {
-				logger.Errorf("consul registry unregister with err: %s", err.Error())
+	done := make(chan struct{}, 1)
+	go func() {
+		defer func() {
+			if e := recover(); e != nil {
+				logger.Errorf("consulRegistry destory with panic: %v", e)
 			}
+			done <- struct{}{}
 		}()
-		select {
-		case <-done:
-			logger.Infof("consulRegistry unregister done")
-		case <-time.After(registryDestroyDefaultTimeout):
-			logger.Errorf("consul unregister timeout")
+		for _, url := range r.registeredURLs {
+			if err := r.UnRegister(url); err != nil {
+				logger.Errorf("consul registry unregister with err: %s", err.Error())
+			}
 		}
+	}()
+	select {
+	case <-done:
+		logger.Infof("consulRegistry unregister done")
+	case <-time.After(registryDestroyDefaultTimeout):

Review comment:
       using `getty.GetTimeWheel().After(registryDestroyDefaultTimeout)` instead.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org