优化结构

This commit is contained in:
Yvan
2026-08-28 16:56:10 +08:00
parent 6f9908d926
commit b370089942
11 changed files with 65 additions and 49 deletions
+17
View File
@@ -92,6 +92,23 @@ func (s *TaskScheduler) Start(ctx context.Context) error {
s.lifecycleMu.Unlock()
if err := s.Reload(runContext); err != nil {
logger.WarnContext(runContext, "timed task table is not ready", "error", err)
go func() {
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
for {
select {
case <-runContext.Done():
return
case <-ticker.C:
if retryErr := s.Reload(runContext); retryErr == nil {
logger.InfoContext(runContext, "timed task table loaded after retry")
return
} else {
logger.WarnContext(runContext, "timed task table retry failed", "error", retryErr)
}
}
}
}()
}
// Stop cancels runContext. Waiting on the child context is important: the
// application lifecycle passes a long-lived parent context to Start and