fix(GODT-2822): retry 429 for metadata and exponential cooldown GODT-2823.

This commit is contained in:
Jakub
2023-07-26 16:11:58 +02:00
parent 25a787529b
commit d7b71aceda
5 changed files with 87 additions and 16 deletions

View File

@ -55,10 +55,6 @@ var (
EventJitter = 20 * time.Second // nolint:gochecknoglobals,revive
)
const (
SyncRetryCooldown = 20 * time.Second
)
type User struct {
log *logrus.Entry
@ -244,13 +240,16 @@ func New(
return
}
cooldown := expCooldown{}
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")
sleepCtx(ctx, SyncRetryCooldown)
wait := cooldown.GetNextWaitTime()
user.log.WithField("retry-after", wait).WithError(err).Error("Failed to sync, will retry later")
sleepCtx(ctx, wait)
} else {
user.log.Info("Sync complete, starting API event stream")
return