| | | 1 | | namespace AsyncResponse.Transports.RabbitMQ; |
| | | 2 | | |
| | | 3 | | internal static class RabbitMqOptionsValidator |
| | | 4 | | { |
| | | 5 | | /// <summary>Validates the supplied options.</summary> |
| | | 6 | | public static string Required(string? value, string name) |
| | 3465 | 7 | | => !string.IsNullOrWhiteSpace(value) |
| | 3465 | 8 | | ? value |
| | 3465 | 9 | | : throw new InvalidOperationException($"{nameof(RabbitMqAsyncResponseOptions)}.{name} must be configured."); |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Bounds the knobs copied verbatim into the RabbitMQ <c>ConnectionFactory</c>, which would |
| | | 13 | | /// otherwise fail at the FIRST connect — long after registration. AMQP 0-9-1 heartbeats are |
| | | 14 | | /// 16-bit seconds (zero disables them). The recovery interval is used directly by the |
| | | 15 | | /// client's automatic-recovery loop as a <c>Task.Delay</c>: a negative value faults (and |
| | | 16 | | /// TERMINATES) that loop and zero spins it, so the interval must be strictly positive and |
| | | 17 | | /// under the timer ceiling — there is no client-side fallback. |
| | | 18 | | /// </summary> |
| | | 19 | | public static void ValidateConnection(RabbitMqAsyncResponseOptions options) |
| | | 20 | | { |
| | 1186 | 21 | | if (options.RequestedHeartbeat < TimeSpan.Zero || options.RequestedHeartbeat > TimeSpan.FromSeconds(ushort.MaxVa |
| | 2 | 22 | | throw new InvalidOperationException( |
| | 2 | 23 | | $"{nameof(RabbitMqAsyncResponseOptions)}.{nameof(options.RequestedHeartbeat)} must be between zero (disa |
| | | 24 | | |
| | 1184 | 25 | | AsyncResponseChannelOptions.EnsureTimerBacked(options.NetworkRecoveryInterval, nameof(RabbitMqAsyncResponseOptio |
| | 1174 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// The mirrored broker <c>consumer_timeout</c> is advertised as the transport's in-flight ceiling |
| | | 30 | | /// (<see cref="IWorkerTransportInFlightLimit.MaxInFlightDuration"/>, whose contract is "positive"), |
| | | 31 | | /// and the durable-flow engine plans in-process waits inside it: zero or a negative value leaves |
| | | 32 | | /// no room for any wait. <c>null</c> (the broker's timeout is disabled) is the way to say "no |
| | | 33 | | /// ceiling". |
| | | 34 | | /// </summary> |
| | | 35 | | public static void ValidateConsumerTimeout(RabbitMqAsyncResponseOptions options) |
| | | 36 | | { |
| | 1134 | 37 | | if (options.BrokerConsumerTimeout is { } consumerTimeout && consumerTimeout <= TimeSpan.Zero) |
| | 0 | 38 | | throw new InvalidOperationException( |
| | 0 | 39 | | $"{nameof(RabbitMqAsyncResponseOptions)}.{nameof(options.BrokerConsumerTimeout)} must be positive, or nu |
| | 1134 | 40 | | } |
| | | 41 | | } |