wenfengwang commented on a change in pull request #97: fix remote timeout unit 
and add shutdown method
URL: https://github.com/apache/rocketmq-client-go/pull/97#discussion_r301385203
 
 

 ##########
 File path: internal/kernel/client.go
 ##########
 @@ -125,44 +129,64 @@ func (c *RMQClient) Start() {
                        // delay
                        time.Sleep(50 * time.Millisecond)
                        for {
-                               c.UpdateTopicRouteInfo()
-                               time.Sleep(_PullNameServerInterval)
+                               if c.state {
+                                       c.UpdateTopicRouteInfo()
+                                       time.Sleep(_PullNameServerInterval)
+                               } else {
+                                       return
+                               }
                        }
                }()
 
                // TODO cleanOfflineBroker & sendHeartbeatToAllBrokerWithLock
                go func() {
                        for {
-                               cleanOfflineBroker()
-                               c.SendHeartbeatToAllBrokerWithLock()
-                               time.Sleep(_HeartbeatBrokerInterval)
+                               if c.state {
+                                       cleanOfflineBroker()
+                                       c.SendHeartbeatToAllBrokerWithLock()
+                                       time.Sleep(_HeartbeatBrokerInterval)
+                               } else {
+                                       return
+                               }
+
                        }
                }()
 
                // schedule persist offset
                go func() {
                        //time.Sleep(10 * time.Second)
                        for {
-                               c.consumerMap.Range(func(key, value 
interface{}) bool {
-                                       consumer := value.(InnerConsumer)
-                                       consumer.PersistConsumerOffset()
-                                       return true
-                               })
-                               time.Sleep(_PersistOffset)
+                               if c.state {
+                                       c.consumerMap.Range(func(key, value 
interface{}) bool {
+                                               consumer := 
value.(InnerConsumer)
+                                               consumer.PersistConsumerOffset()
+                                               return true
+                                       })
+                                       time.Sleep(_PersistOffset)
+                               } else {
+                                       return
+                               }
+
                        }
                }()
 
                go func() {
                        for {
-                               c.RebalanceImmediately()
 
 Review comment:
   > below is better?
   > 
   > ```
   > for !c.close {
   >   c.UpdateTopicRouteInfo()
   >   time.Sleep(_PullNameServerInterval)
   > }
   > ```
   
   

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