重构了一下 rag的方法, 使用 goframe的框架, 还有redis连接部分
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user