chore: avoid repull too fast

This commit is contained in:
langhuihui
2023-09-07 13:06:49 +08:00
parent 934d3cf9d4
commit 03d22736d5
+5 -1
View File
@@ -54,7 +54,12 @@ func (pub *Puller) startPull(puller IPuller) {
}
}()
puber := puller.GetPublisher()
startTime := time.Now()
for puller.Info("start pull"); puller.Reconnect(); puller.Warn("restart pull") {
if time.Since(startTime) < 5*time.Second {
time.Sleep(5 * time.Second)
}
startTime = time.Now()
if err = puller.Connect(); err != nil {
if err == io.EOF {
puller.Info("pull complete")
@@ -64,7 +69,6 @@ func (pub *Puller) startPull(puller IPuller) {
if badPuller {
return
}
time.Sleep(time.Second * 5)
} else {
if err = puller.Publish(pub.StreamPath, puller); err != nil {
puller.Error("pull publish", zap.Error(err))