< Summary - AsyncResponse (Release / net8.0+net10.0 / unit+integration)

Information
Class: AsyncResponse.Transports.RabbitMQ.RabbitMqOptionsValidator
Assembly: AsyncResponse.Transports.RabbitMQ
File(s): /_/src/Transports/AsyncResponse.Transports.RabbitMQ/RabbitMqOptionsValidator.cs
Line coverage
83%
Covered lines: 10
Uncovered lines: 2
Coverable lines: 12
Total lines: 41
Line coverage: 83.3%
Branch coverage
80%
Covered branches: 8
Total branches: 10
Branch coverage: 80%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Required(...)100%22100%
ValidateConnection(...)75%44100%
ValidateConsumerTimeout(...)75%6450%

File(s)

/_/src/Transports/AsyncResponse.Transports.RabbitMQ/RabbitMqOptionsValidator.cs

#LineLine coverage
 1namespace AsyncResponse.Transports.RabbitMQ;
 2
 3internal static class RabbitMqOptionsValidator
 4{
 5    /// <summary>Validates the supplied options.</summary>
 6    public static string Required(string? value, string name)
 34657        => !string.IsNullOrWhiteSpace(value)
 34658            ? value
 34659            : 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    {
 118621        if (options.RequestedHeartbeat < TimeSpan.Zero || options.RequestedHeartbeat > TimeSpan.FromSeconds(ushort.MaxVa
 222            throw new InvalidOperationException(
 223                $"{nameof(RabbitMqAsyncResponseOptions)}.{nameof(options.RequestedHeartbeat)} must be between zero (disa
 24
 118425        AsyncResponseChannelOptions.EnsureTimerBacked(options.NetworkRecoveryInterval, nameof(RabbitMqAsyncResponseOptio
 117426    }
 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    {
 113437        if (options.BrokerConsumerTimeout is { } consumerTimeout && consumerTimeout <= TimeSpan.Zero)
 038            throw new InvalidOperationException(
 039                $"{nameof(RabbitMqAsyncResponseOptions)}.{nameof(options.BrokerConsumerTimeout)} must be positive, or nu
 113440    }
 41}