ShiKaiWi commented on issue #1165:
URL: 
https://github.com/apache/rocketmq-clients/issues/1165#issuecomment-4563656654

   @lizhimins The current implementation can be confusing for users. When 
WithTopics() is not configured, the log repeatedly prints "wait for sync 
settings finish" indefinitely, which misleads users into suspecting a network 
issue between the client and the server, when in fact the root cause is a 
missing configuration.
   
   I'd like to propose a minor, non-breaking improvement to the logging 
behavior: when the client has been waiting for settings synchronization for an 
extended period (e.g. 30 seconds) and initTopics is empty, the log message 
should include additional diagnostic details indicating that no initial topics 
were configured. This would help users quickly identify the root cause without 
changing any existing behavior or control flow.
   
   Here is a simple code snippet to illustrate the idea:
   ```go
   startTime := time.Now()
   for !cli.inited.Load() {
       if len(cli.initTopics) == 0 && time.Since(startTime) > 30*time.Second {
           sugarBaseLogger.Warnf("wait for sync settings finish, but no initial 
topics configured via WithTopics(). "+
               "The client cannot establish a telemetry connection without at 
least one topic. "+
               "Elapsed: %v", time.Since(startTime))
       } else {
           sugarBaseLogger.Infoln("wait for sync settings finish")
       }
       time.Sleep(time.Second)
   }
   sugarBaseLogger.Infoln("sync settings finished") 
   ```
   
   I'm glad to submit a pull request if you aggre with this solution.


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