添加消息队列消费者并优化租户存储总量更新逻辑

This commit is contained in:
2026-01-22 15:06:30 +08:00
parent 542c609d60
commit 4a1531fddb
4 changed files with 35 additions and 7 deletions

17
main.go
View File

@@ -2,6 +2,9 @@ package main
import (
"context"
"gitee.com/red-future---jilin-g/common/log/consts"
"gitee.com/red-future---jilin-g/common/message"
"gitee.com/red-future---jilin-g/common/mongo"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/os/gtimer"
"oss/controller"
@@ -10,7 +13,7 @@ import (
"gitee.com/red-future---jilin-g/common/http"
"gitee.com/red-future---jilin-g/common/jaeger"
_ "gitee.com/red-future---jilin-g/common/mongo"
logService "gitee.com/red-future---jilin-g/common/log/service"
_ "github.com/gogf/gf/contrib/nosql/redis/v2"
)
@@ -30,6 +33,18 @@ func main() {
}
})
// 启动消息队列消费者
if err := message.StartConsumers(ctx, &message.RedisMessageConfig{
StreamKey: mongo.LogRedisKey,
GroupName: consts.GroupName,
ConsumerName: consts.ConsumerName,
BatchSize: consts.BatchSize,
AutoAck: consts.AutoAck,
HandleFunc: logService.OperationLog.AddOperationLog,
}); err != nil {
return
}
// 保持应用运行
select {}
}