(ctx context.Context)
| 176 | } |
| 177 | |
| 178 | func (s *sourceManager) runLocal(ctx context.Context) { |
| 179 | if s.isPaused() { |
| 180 | s.setStatus("PAUSED") |
| 181 | } else { |
| 182 | s.setStatus("IDLE") |
| 183 | } |
| 184 | |
| 185 | for { |
| 186 | select { |
| 187 | case <-s.closed: |
| 188 | return |
| 189 | |
| 190 | case <-s.snapshotRequests: |
| 191 | if s.isPaused() { |
| 192 | s.setStatus("PAUSED") |
| 193 | |
| 194 | continue |
| 195 | } |
| 196 | |
| 197 | s.setStatus("PENDING") |
| 198 | |
| 199 | userLog(ctx).Debugw("snapshotting", "source", s.src) |
| 200 | |
| 201 | if err := s.server.runSnapshotTask(ctx, s.src, s.snapshotInternal); err != nil { |
| 202 | userLog(ctx).Errorf("snapshot error: %v", err) |
| 203 | |
| 204 | s.backoffBeforeNextSnapshot() |
| 205 | } else { |
| 206 | s.refreshStatus(ctx) |
| 207 | } |
| 208 | |
| 209 | s.server.refreshScheduler("snapshot finished") |
| 210 | |
| 211 | s.setStatus("IDLE") |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | func (s *sourceManager) backoffBeforeNextSnapshot() { |
| 217 | if _, ok := s.getNextSnapshotTime(); !ok { |
no test coverage detected