gosonzhang commented on code in PR #11582:
URL: https://github.com/apache/inlong/pull/11582#discussion_r1872513487


##########
inlong-tubemq/tubemq-client-twins/tubemq-client-go/client/consumer_impl.go:
##########
@@ -105,72 +106,92 @@ func NewConsumer(config *config.Config) (Consumer, error) 
{
                client:          client,
                visitToken:      util.InvalidValue,
                unreportedTimes: 0,
-               done:            make(chan struct{}),
+               routineClosed:   make(chan struct{}),
        }
+
+       ctx := context.Background()
+       ctx, c.cancel = context.WithCancel(ctx)
+
        c.subInfo.SetClientID(clientID)
        hbm := newHBManager(c)
        c.heartbeatManager = hbm
-       err = c.register2Master(true)
-       if err != nil {
-               return nil, err
-       }
-       c.heartbeatManager.registerMaster(c.master.Address)
-       go c.processRebalanceEvent()
+
+       go c.routine(ctx)
+       go c.processRebalanceEvent(ctx)
+
        log.Infof("[CONSUMER] start consumer success, client=%s", clientID)
        return c, nil
 }
 
-func (c *consumer) register2Master(needChange bool) error {
-       if needChange {
-               c.selector.Refresh(c.config.Consumer.Masters)
+func (c *consumer) routine(ctx context.Context) {
+       defer close(c.routineClosed)
+
+       for {
+               select {
+               case <-ctx.Done():
+                       return
+               default:
+               }
+               // 选主

Review Comment:
   To make it easier for more people to understand, please use English 
annotations



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

Reply via email to