Browse Source

[fix] Retrier

ksuid v0.2.18
loveckiy.ivan 3 months ago
parent
commit
5a9f8edf01
  1. 7
      async.go

7
async.go

@ -31,11 +31,16 @@ func Recover(ctx context.Context) (flag bool, msg string) {
func Retrier[T any](
maxCountRetries int,
timeRetries time.Duration,
disableProgressCalc bool,
f func() (T, error),
) (res T, err error) {
for i := 0; i < maxCountRetries; i++ {
if i > 0 {
time.Sleep(sleepCalc(i, timeRetries))
if disableProgressCalc {
time.Sleep(timeRetries)
} else {
time.Sleep(sleepCalc(i, timeRetries))
}
}
res, err = f()

Loading…
Cancel
Save