Method
logAndWait
(ctx context.Context, err error)
Source from the content-addressed store, hash-verified
| 24 | } |
| 25 | |
| 26 | func (l *Loop) logAndWait(ctx context.Context, err error) { |
| 27 | if err != nil { |
| 28 | l.logger.Error(err.Error()) |
| 29 | } |
| 30 | l.logger.Info("retrying in " + l.backoffTime.String()) |
| 31 | timer := time.NewTimer(l.backoffTime) |
| 32 | l.backoffTime *= 2 |
| 33 | select { |
| 34 | case <-timer.C: |
| 35 | case <-ctx.Done(): |
| 36 | if !timer.Stop() { |
| 37 | <-timer.C |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | const defaultBackoffTime = 10 * time.Second |
| 43 | |
Tested by
no test coverage detected