func()

in spark/client/retry.go [113:137]


func (rs *retryState) nextAttempt(p RetryPolicy) *time.Duration {
	if rs.retryCount >= p.MaxRetries {
		return nil
	}

	// For the first retry pick the initial backoff of the matching policy.
	if rs.retryCount == 0 {
		rs.nextWait = p.InitialBackoff
	}

	// Adjust the retry count and calculate the next wait.
	rs.retryCount++
	wait := rs.nextWait
	rs.nextWait = time.Duration(float32(rs.nextWait.Milliseconds())*p.BackoffMultiplier) * time.Millisecond
	if rs.nextWait > p.MaxBackoff {
		rs.nextWait = p.MaxBackoff
	}

	// Some policies define that jitter should only be applied after a particular threshold.
	if wait > p.MinJitterThreshold {
		wait += time.Duration(rand.Float32() * float32(p.Jitter.Milliseconds()))
	}

	return &wait
}