func (c *RetryConfig) RetryFunc() RetryFunc {
	return func(retry int) (bool, time.Duration) {
		if !BoolVal(c.Enabled) {
			return false, 0
		}

		if IntVal(c.Attempts) > 0 && retry > IntVal(c.Attempts)-1 {
			return false, 0
		}

		baseSleep := TimeDurationVal(c.Backoff)
		maxSleep := TimeDurationVal(c.MaxBackoff)

		if maxSleep > 0 {
			attemptsTillMaxBackoff := int(math.Log2(maxSleep.Seconds() / baseSleep.Seconds()))
			if retry > attemptsTillMaxBackoff {
				return true, maxSleep
			}
		}

		base := math.Pow(2, float64(retry))
		sleep := time.Duration(base) * baseSleep

		return true, sleep
	}
}
func (c *RetryConfig) RetryFunc() RetryFunc {
	return func(retry int) (bool, time.Duration) {
		if !BoolVal(c.Enabled) {
			return false, 0
		}

		if IntVal(c.Attempts) > 0 && retry > IntVal(c.Attempts)-1 {
			return false, 0
		}

		baseSleep := TimeDurationVal(c.Backoff)
		maxSleep := TimeDurationVal(c.MaxBackoff)

		if maxSleep > 0 {
			attemptsTillMaxBackoff := int(math.Log2(maxSleep.Seconds() / baseSleep.Seconds()))
			if retry > attemptsTillMaxBackoff {
				return true, maxSleep
			}
		}

		base := math.Pow(2, float64(retry))
		sleep := time.Duration(base) * baseSleep

		return true, sleep
	}
}
// RetryFunc returns the retry function associated with this configuration.