func (b *Backoff) Step() time.Duration {
	if b.Steps < 1 {
		if b.Jitter > 0 {
			return jitter(b.Duration, b.Jitter)
		}
		return b.Duration
	}
	b.Steps--

	duration := b.Duration

	// calculate the next step
	if b.Factor != 0 {
		b.Duration = time.Duration(float64(b.Duration) * b.Factor)
		if b.Cap > 0 && b.Duration > b.Cap {
			b.Duration = b.Cap
			b.Steps = 0
		}
	}

	if b.Jitter > 0 {
		duration = jitter(duration, b.Jitter)
	}
	return duration
}
// Step (1) returns an amount of time to sleep determined by the
// original Duration and Jitter and (2) mutates the provided Backoff
// to update its Steps and Duration.
Step (1) returns an amount of time to sleep determined by the
original Duration and Jitter and (2) mutates the provided Backoff
to update its Steps and Duration.
// Step ( 1 ) returns an amount of time to sleep determined by the // original Duration and Jitter and ( 2 ) mutates the provided Backoff // to update its Steps and Duration .
func (b *Backoff) Step() time.Duration {
	if b.Steps < 1 {
		if b.Jitter > 0 {
			return jitter(b.Duration, b.Jitter)
		}
		return b.Duration
	}
	b.Steps--
	duration := b.Duration
	if b.Factor != 0 {
		b.Duration = time.Duration(float64(b.Duration) * b.Factor)
		if b.Cap > 0 && b.Duration > b.Cap {
			b.Duration = b.Cap
			b.Steps = 0
		}
	}
	if b.Jitter > 0 {
		duration = jitter(duration, b.Jitter)
	}
	return duration
}
func ( b * Backoff ) Step ( ) time . Duration { if b . Steps < 1 { if b . Jitter > 0 { return jitter ( b . Duration , b . Jitter ) } return b . Duration } b . Steps -- duration := b . Duration if b . Factor != 0 { b . Duration = time . Duration ( float64 ( b . Duration ) * b . Factor ) if b . Cap > 0 && b . Duration > b . Cap { b . Duration = b . Cap b . Steps = 0 } } if b . Jitter > 0 { duration = jitter ( duration , b . Jitter ) } return duration }
Step (1) returns an amount of time to sleep determined by the
original Duration and Jitter and (2) mutates the provided Backoff
to update its Steps and Duration.
Step ( 1 ) returns an amount of time to sleep determined by the original Duration and Jitter and ( 2 ) mutates the provided Backoff to update its Steps and Duration .
// calculate the next step