mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-07 04:20:12 +02:00
2998cf5e48
- portforward package - portforward run loop - Less functional arguments and cycles
23 lines
367 B
Go
23 lines
367 B
Go
package portforward
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
func (l *Loop) logAndWait(ctx context.Context, err error) {
|
|
if err != nil {
|
|
l.logger.Error(err.Error())
|
|
}
|
|
l.logger.Info("retrying in " + l.backoffTime.String())
|
|
timer := time.NewTimer(l.backoffTime)
|
|
l.backoffTime *= 2
|
|
select {
|
|
case <-timer.C:
|
|
case <-ctx.Done():
|
|
if !timer.Stop() {
|
|
<-timer.C
|
|
}
|
|
}
|
|
}
|