moves bulk of code from ticker case to outside for indentation's sake (#559)
* moves bulk of code from ticker case to outside for indentation's sake * adds whitespace * removes break
This commit is contained in:
parent
1fb96689b8
commit
7ae2fa3575
@ -130,12 +130,13 @@ func (c *checker) Run(ctx context.Context) (err error) {
|
||||
for {
|
||||
select {
|
||||
case <-c.ticker.C: // wait for the next interval to happen
|
||||
err = c.IdentifyInjuredSegments(ctx)
|
||||
if err != nil {
|
||||
zap.L().Error("Checker failed", zap.Error(err))
|
||||
}
|
||||
case <-ctx.Done(): // or the checker is canceled via context
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
err = c.IdentifyInjuredSegments(ctx)
|
||||
if err != nil {
|
||||
zap.L().Error("Checker failed", zap.Error(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,22 +45,23 @@ func (r *repairer) Run(ctx context.Context) (err error) {
|
||||
for {
|
||||
select {
|
||||
case <-r.ticker.C: // wait for the next interval to happen
|
||||
seg, err := r.queue.Dequeue()
|
||||
if err != nil {
|
||||
// TODO: only log when err != ErrQueueEmpty
|
||||
zap.L().Error("dequeue", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
r.limiter.Go(ctx, func() {
|
||||
err := r.Repair(ctx, &seg)
|
||||
if err != nil {
|
||||
zap.L().Error("Repair failed", zap.Error(err))
|
||||
}
|
||||
})
|
||||
case <-ctx.Done(): // or the repairer is canceled via context
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
seg, err := r.queue.Dequeue()
|
||||
if err != nil {
|
||||
// TODO: only log when err != ErrQueueEmpty
|
||||
zap.L().Error("dequeue", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
r.limiter.Go(ctx, func() {
|
||||
err := r.Repair(ctx, &seg)
|
||||
if err != nil {
|
||||
zap.L().Error("Repair failed", zap.Error(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user