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:
Jennifer Li Johnson 2018-10-30 16:14:15 -04:00 committed by GitHub
parent 1fb96689b8
commit 7ae2fa3575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 17 deletions

View File

@ -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))
}
}
}

View File

@ -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))
}
})
}
}