feat: 重构异步模型字段并更新依赖
This commit is contained in:
27
main.go
27
main.go
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user