Files
2026-08-27 00:43:08 +03:00

24 lines
440 B
Go

package playback
import "time"
func (p RetryPolicy) canRetry(failedAttempts int) bool {
return p.MaxAttempts == 0 || failedAttempts < p.MaxAttempts
}
func (p RetryPolicy) retryDelay(failedAttempts int) time.Duration {
delay := p.InitialDelay
for attempt := 1; attempt < failedAttempts; attempt++ {
if delay >= p.MaxDelay/2 {
return p.MaxDelay
}
delay *= 2
}
if delay > p.MaxDelay {
return p.MaxDelay
}
return delay
}