snapshotLoop runs periodic writeSnapshot while the scheduler is up.
()
| 195 | |
| 196 | // snapshotLoop runs periodic writeSnapshot while the scheduler is up. |
| 197 | func (s *Scheduler) snapshotLoop() { |
| 198 | defer close(s.snapDone) |
| 199 | if s.cfg.SnapshotInterval <= 0 { |
| 200 | return |
| 201 | } |
| 202 | t := time.NewTicker(s.cfg.SnapshotInterval) |
| 203 | defer t.Stop() |
| 204 | for { |
| 205 | select { |
| 206 | case <-s.ctx.Done(): |
| 207 | return |
| 208 | case <-t.C: |
| 209 | if err := s.writeSnapshotNow(); err != nil { |
| 210 | s.logger.Warn("scheduler: snapshot failed", zap.Error(err)) |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | // gcLoop reaps terminal jobs past TTL. |
| 217 | func (s *Scheduler) gcLoop() { |
no test coverage detected