feat: 重构异步模型字段并更新依赖

This commit is contained in:
2026-06-08 18:01:53 +08:00
parent 9049e0d2e8
commit 0cf8948cd2
11 changed files with 512 additions and 441 deletions

27
main.go
View File

@@ -47,33 +47,6 @@ func main() {
}
func startAutoRunner(ctx context.Context) {
// worker
if g.Cfg().MustGet(ctx, "asynch.worker.enabled").Bool() {
interval := g.Cfg().MustGet(ctx, "asynch.worker.intervalSeconds").Int()
if interval <= 0 {
interval = 5
}
batchSize := g.Cfg().MustGet(ctx, "asynch.worker.batchSize").Int()
goroutines := g.Cfg().MustGet(ctx, "asynch.worker.goroutines").Int()
ticker := time.NewTicker(time.Duration(interval) * time.Second)
go func() {
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
if _, err := task.AsyncWorker.RunOnce(ctx, &dto.RunWorkReq{
BatchSize: batchSize,
Goroutines: goroutines,
}); err != nil {
g.Log().Warningf(ctx, "[auto-worker] run once failed: %v", err)
}
}
}
}()
}
// cleaner
if g.Cfg().MustGet(ctx, "asynch.cleaner.enabled").Bool() {
interval := g.Cfg().MustGet(ctx, "asynch.cleaner.intervalSeconds").Int()