Other: Retry sync after cooldown if it fails

This commit is contained in:
James Houlahan
2022-11-23 12:47:16 +01:00
parent 555453bc1a
commit 61287d05bf

View File

@ -48,6 +48,10 @@ var (
EventJitter = 20 * time.Second // nolint:gochecknoglobals,revive EventJitter = 20 * time.Second // nolint:gochecknoglobals,revive
) )
const (
SyncRetryCooldown = 20 * time.Second
)
type User struct { type User struct {
log *logrus.Entry log *logrus.Entry
@ -218,7 +222,8 @@ func New(
if user.vault.SyncStatus().IsComplete() { if user.vault.SyncStatus().IsComplete() {
user.log.Debug("Sync is already complete, skipping") user.log.Debug("Sync is already complete, skipping")
} else if err := user.doSync(ctx); err != nil { } else if err := user.doSync(ctx); err != nil {
user.log.WithError(err).Error("Failed to sync") user.log.WithError(err).Error("Failed to sync, will retry later")
time.AfterFunc(SyncRetryCooldown, user.goSync)
} }
}) })
}) })