重构了一下 rag的方法, 使用 goframe的框架, 还有redis连接部分

This commit is contained in:
Cold
2025-12-06 18:04:29 +08:00
committed by 张斌
parent f7cb007491
commit 4b2b5e6177
16 changed files with 398 additions and 260 deletions

View File

@@ -149,12 +149,18 @@ func (q *QueueProcessor) Start(ctx context.Context) error {
glog.Infof(ctx, "Stream 处理器启动 - Stream: %s, 消费者组: %s, 消费者: %s, 超时: %dms",
q.streamKey, q.groupName, q.consumerName, q.timeout)
loopCount := 0
for {
select {
case <-q.stopChan:
glog.Info(ctx, "Stream 处理器收到停止信号")
return nil
default:
loopCount++
if loopCount%10 == 1 {
glog.Debugf(ctx, "[DEBUG] 第 %d 次循环,准备读取消息...", loopCount)
}
// 从 Redis Stream 中读取消息
messages, err := q.fetchMessages(ctx)
if err != nil {
@@ -164,11 +170,17 @@ func (q *QueueProcessor) Start(ctx context.Context) error {
// 没有新消息,继续等待
if len(messages) == 0 {
if loopCount%10 == 1 {
glog.Debugf(ctx, "[DEBUG] 第 %d 次循环,无新消息", loopCount)
}
continue
}
glog.Infof(ctx, "[DEBUG] 收到 %d 条消息", len(messages))
// 处理每条消息
for _, msg := range messages {
glog.Infof(ctx, "[DEBUG] 处理消息 ID: %s, Values: %+v", msg.ID, msg.Values)
// 提交到协程池处理
if err := q.submitTask(ctx, msg); err != nil {
glog.Errorf(ctx, "提交任务到协程池失败: %v, 消息ID: %s", err, msg.ID)