in src/Microsoft.Extensions.Configuration.AzureAppConfiguration/Extensions/TimeSpanExtensions.cs [31:61]
public static TimeSpan CalculateBackoffTime(this TimeSpan interval, TimeSpan min, TimeSpan max, int attempts)
{
if (interval <= TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(interval), interval, "The time interval should not be equal to or less than 0.");
}
if (min <= TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(min), min, "The minimum backoff time should not be equal to or less than 0.");
}
if (max < min)
{
throw new ArgumentOutOfRangeException(nameof(max), max, "The maximum backoff time should not be less than the minimum backoff time.");
}
if (attempts < 1)
{
throw new ArgumentOutOfRangeException(nameof(attempts), attempts, "The number of attempts should not be less than 1.");
}
if (interval <= min)
{
return interval;
}
max = TimeSpan.FromTicks(Math.Min(interval.Ticks, max.Ticks));
return min.CalculateBackoffDuration(max, attempts);
}