namespace MxGateway.Client; public sealed class MxGatewayClientRetryOptions { public int MaxAttempts { get; init; } = 2; public TimeSpan Delay { get; init; } = TimeSpan.FromMilliseconds(200); public TimeSpan MaxDelay { get; init; } = TimeSpan.FromSeconds(2); public bool UseJitter { get; init; } = true; public void Validate() { if (MaxAttempts <= 0) { throw new ArgumentOutOfRangeException( nameof(MaxAttempts), "The retry max attempts value must be greater than zero."); } if (Delay <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException( nameof(Delay), "The retry delay must be greater than zero."); } if (MaxDelay <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException( nameof(MaxDelay), "The retry max delay must be greater than zero."); } if (MaxDelay < Delay) { throw new ArgumentOutOfRangeException( nameof(MaxDelay), "The retry max delay must be greater than or equal to the retry delay."); } } }