Compare commits
No commits in common. "master" and "feature/rzy/report_combine" have entirely different histories.
master
...
feature/rz
|
|
@ -115,7 +115,6 @@ func (s *SendCardClient) NewCard(ctx context.Context, cardSend *CardSend) error
|
|||
s.processContentChannel(ctx, cardSend, cardInstanceId.String(), client)
|
||||
}()
|
||||
wg.Wait()
|
||||
log.Info("处理通道结束")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -164,7 +163,7 @@ func (s *SendCardClient) processContentChannel(ctx context.Context, cardSend *Ca
|
|||
|
||||
var (
|
||||
contentBuilder strings.Builder
|
||||
lastUpdate = time.Now()
|
||||
lastUpdate time.Time
|
||||
)
|
||||
for {
|
||||
|
||||
|
|
@ -174,7 +173,6 @@ func (s *SendCardClient) processContentChannel(ctx context.Context, cardSend *Ca
|
|||
// 通道关闭,发送最终内容
|
||||
if contentBuilder.Len() > 0 {
|
||||
if err := s.updateCardContent(ctx, cardSend, cardInstanceId, contentBuilder.String(), client); err != nil {
|
||||
log.Info("contentBuilder.Len()修改失败1")
|
||||
s.logger.Errorf("更新卡片失败1:%s", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
@ -183,7 +181,6 @@ func (s *SendCardClient) processContentChannel(ctx context.Context, cardSend *Ca
|
|||
contentBuilder.WriteString(content)
|
||||
if contentBuilder.Len() > 0 {
|
||||
if err := s.updateCardContent(ctx, cardSend, cardInstanceId, contentBuilder.String(), client); err != nil {
|
||||
log.Info("contentBuilder.Len()修改失败2")
|
||||
s.logger.Errorf("更新卡片失败2:%s", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
@ -191,12 +188,10 @@ func (s *SendCardClient) processContentChannel(ctx context.Context, cardSend *Ca
|
|||
|
||||
case <-heartbeatTicker.C:
|
||||
if time.Now().Unix()-lastUpdate.Unix() >= HeardBeatX {
|
||||
log.Infof("心跳超时,当前时间:%d,最后时间:%d", time.Now().Unix(), lastUpdate.Unix())
|
||||
return
|
||||
}
|
||||
|
||||
case <-ctx.Done():
|
||||
log.Info("send_card上下文失效")
|
||||
s.logger.Info("context canceled, stop channel processing")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,15 +64,9 @@ func (d *DingBotService) runBackgroundTasks(ctx context.Context, data *chatbot.B
|
|||
g.Go(func() error {
|
||||
defer func() {
|
||||
// 确保通道最终关闭
|
||||
log.Println("流式处理协程关闭")
|
||||
|
||||
close(resChan)
|
||||
}()
|
||||
err := d.dingTalkBotBiz.HandleStreamRes(ctx, data, resChan)
|
||||
if err != nil {
|
||||
log.Println("流式回复产生错误,错误:", err.Error())
|
||||
}
|
||||
return err
|
||||
return d.dingTalkBotBiz.HandleStreamRes(ctx, data, resChan)
|
||||
})
|
||||
|
||||
// 2. 业务处理协程(负责关闭requireData.Ch)
|
||||
|
|
|
|||
Loading…
Reference in New Issue