fix: sleep issues

This commit is contained in:
Rogee
2024-09-05 15:56:27 +08:00
parent fac2ecdf64
commit ade4a0ef7f

View File

@@ -3,7 +3,6 @@ package internal
import (
"context"
"log"
"math"
"time"
"exporter/config"
@@ -52,13 +51,12 @@ func channelExportCmd(ctx context.Context) error {
if err := client.Channel(ctx, channel, cfg, false); err != nil {
logger.Error("failed to export channel", zap.Error(err), zap.Int64("uuid", channel.GetID()))
continueRetryTimes++
sleepSeconds := math.Pow(2, float64(1+continueRetryTimes))
if sleepSeconds > 128 {
if continueRetryTimes > 6 {
return err
}
logger.Info("retry after", zap.Int("seconds", int(sleepSeconds)))
time.Sleep(time.Second * time.Duration(sleepSeconds))
logger.Info("retry after 1 min")
time.Sleep(time.Minute)
continue
}