1kasa commented on code in PR #2879: URL: https://github.com/apache/dubbo-go/pull/2879#discussion_r2094154919
########## registry/nacos/registry.go: ########## @@ -359,12 +370,46 @@ func (nr *nacosRegistry) GetURL() *common.URL { // IsAvailable determines nacos registry center whether it is available func (nr *nacosRegistry) IsAvailable() bool { - // TODO - return true + // Considering both local state + server state + select { + case <-nr.done: + return false + default: + } + + mu.Lock() + defer mu.Unlock() + + if time.Since(lastCheckTime) < checkInterval { + return lastAvailable + } + + lastCheckTime = time.Now() + + if nr.namingClient == nil || nr.namingClient.Client() == nil { + lastAvailable = false + return false + } + + // Verify whether nacos is available through the lightweight nacos API + _, err := nr.namingClient.Client().GetAllServicesInfo(vo.GetAllServiceInfoParam{ + GroupName: nr.GetParam(constant.RegistryGroupKey, defaultGroup), + PageNo: 1, + PageSize: 1, + }) + lastAvailable = err == nil + return lastAvailable } // nolint Review Comment: Deleted,done -- 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: notifications-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org