From ba5e5b3d1cde47c260162d7dbfdda656f2ddb34c Mon Sep 17 00:00:00 2001 From: douxu Date: Fri, 16 Jan 2026 17:08:28 +0800 Subject: [PATCH] optimzie code of constants package --- constants/{resp_code.go => response_code.go} | 0 handler/real_time_data_pull.go | 5 ++--- 2 files changed, 2 insertions(+), 3 deletions(-) rename constants/{resp_code.go => response_code.go} (100%) diff --git a/constants/resp_code.go b/constants/response_code.go similarity index 100% rename from constants/resp_code.go rename to constants/response_code.go diff --git a/handler/real_time_data_pull.go b/handler/real_time_data_pull.go index 30c009d..c190ff1 100644 --- a/handler/real_time_data_pull.go +++ b/handler/real_time_data_pull.go @@ -164,6 +164,7 @@ func sendAggregateRealTimeDataStream(conn *websocket.Conn, targetsData []network return conn.WriteJSON(response) } +// sendDataStream define func to manages a dedicated goroutine to push data batches or system signals to the websocket client func sendDataStream(ctx context.Context, conn *websocket.Conn, clientID string, sendChan <-chan []network.RealTimePullTarget, cancel context.CancelFunc) { logger.Info(ctx, "start dedicated websocket sender goroutine", "client_id", clientID) for targetsData := range sendChan { @@ -192,7 +193,7 @@ func sendDataStream(ctx context.Context, conn *websocket.Conn, clientID string, logger.Info(ctx, "sender goroutine exiting as channel is closed", "client_id", clientID) } -// processTargetPolling define function to process target in subscription map and data is continuously retrieved from redis based on the target +// processTargetPolling define func to process target in subscription map and data is continuously retrieved from redis based on the target func processTargetPolling(ctx context.Context, s *SharedSubState, clientID string, fanInChan chan network.RealTimePullTarget, sendChan chan<- []network.RealTimePullTarget) { // ensure the fanInChan will not leak defer close(fanInChan) @@ -207,8 +208,6 @@ func processTargetPolling(ctx context.Context, s *SharedSubState, clientID strin } s.globalMutex.RUnlock() - logger.Info(ctx, fmt.Sprintf("found subscription config for clientID:%s, start initial polling goroutines", clientID), "components len", config.measurements) - config.mutex.RLock() for interval, measurementTargets := range config.measurements { for _, target := range measurementTargets {