优化结构
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user