Ensure valid timeout settings in ExponentialRetry by gliljas · Pull Request #1921 · StackExchange/StackExchange.Redis

Expand Up @@ -16,7 +16,7 @@ public class ExponentialRetry : IReconnectRetryPolicy /// Initializes a new instance using the specified back off interval with default maxDeltaBackOffMilliseconds of 10 seconds. /// </summary> /// <param name="deltaBackOffMilliseconds">time in milliseconds for the back-off interval between retries</param> public ExponentialRetry(int deltaBackOffMilliseconds) : this(deltaBackOffMilliseconds, (int)TimeSpan.FromSeconds(10).TotalMilliseconds) {} public ExponentialRetry(int deltaBackOffMilliseconds) : this(deltaBackOffMilliseconds, Math.Max(deltaBackOffMilliseconds, (int)TimeSpan.FromSeconds(10).TotalMilliseconds)) { }
/// <summary> /// Initializes a new instance using the specified back off interval. Expand All @@ -25,6 +25,19 @@ public ExponentialRetry(int deltaBackOffMilliseconds) : this(deltaBackOffMillise /// <param name="maxDeltaBackOffMilliseconds">time in milliseconds for the maximum value that the back-off interval can exponentially grow up to.</param> public ExponentialRetry(int deltaBackOffMilliseconds, int maxDeltaBackOffMilliseconds) { if (deltaBackOffMilliseconds < 0) { throw new ArgumentOutOfRangeException(nameof(deltaBackOffMilliseconds), $"{nameof(deltaBackOffMilliseconds)} must be greater than or equal to zero"); } if (maxDeltaBackOffMilliseconds < 0) { throw new ArgumentOutOfRangeException(nameof(maxDeltaBackOffMilliseconds), $"{nameof(maxDeltaBackOffMilliseconds)} must be greater than or equal to zero"); } if (maxDeltaBackOffMilliseconds < deltaBackOffMilliseconds) { throw new ArgumentOutOfRangeException(nameof(maxDeltaBackOffMilliseconds), $"{nameof(maxDeltaBackOffMilliseconds)} must be greater than or equal to {nameof(deltaBackOffMilliseconds)}"); }
this.deltaBackOffMilliseconds = deltaBackOffMilliseconds; this.maxDeltaBackOffMilliseconds = maxDeltaBackOffMilliseconds; } Expand Down