xujianhai666 commented on a change in pull request #303: [ISSUE #293] Optimize 
Close of rmqClient
URL: https://github.com/apache/rocketmq-client-go/pull/303#discussion_r347749919
 
 

 ##########
 File path: internal/client.go
 ##########
 @@ -228,63 +231,92 @@ func GetOrNewRocketMQClient(option ClientOptions, 
callbackCh chan interface{}) *
 func (c *rmqClient) Start() {
        //ctx, cancel := context.WithCancel(context.Background())
        //c.cancel = cancel
-       c.close = false
        c.once.Do(func() {
-               // TODO fetchNameServerAddr
                if !c.option.Credentials.IsEmpty() {
                        
c.remoteClient.RegisterInterceptor(remote.ACLInterceptor(c.option.Credentials))
                }
+               // TODO fetchNameServerAddr
                go func() {}()
 
                // schedule update route info
                go func() {
                        // delay
+                       ticker := time.NewTicker(_PullNameServerInterval)
+                       defer ticker.Stop()
                        time.Sleep(50 * time.Millisecond)
-                       for !c.close {
-                               c.UpdateTopicRouteInfo()
-                               time.Sleep(_PullNameServerInterval)
+                       for {
+                               select {
+                               case <-ticker.C:
+                                       c.UpdateTopicRouteInfo()
+                               case <-c.done:
+                                       rlog.Info("Stopping update topic route 
info", nil)
 
 Review comment:
   maybe more info should be provided. for example, clientId group topic etc....

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to