fix(GODT-2327): Loop to retry until sync has complete

This commit is contained in:
James Houlahan
2023-02-07 09:59:46 +01:00
committed by Jakub
parent 9c6be78b4c
commit 20d83dd476

View File

@ -194,9 +194,17 @@ func New(
return
}
if err := user.doSync(ctx); err != nil {
user.log.WithError(err).Error("Failed to sync, will retry later")
time.AfterFunc(SyncRetryCooldown, user.goSync)
for {
if err := ctx.Err(); err != nil {
user.log.WithError(err).Error("Sync aborted")
return
} else if err := user.doSync(ctx); err != nil {
user.log.WithError(err).Error("Failed to sync, will retry later")
time.Sleep(SyncRetryCooldown)
} else {
user.log.Info("Sync complete, starting API event stream")
return
}
}
})