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

Information
Class: AsyncResponse.Transports.Kafka.KafkaTransportOptionsValidator
Assembly: AsyncResponse.Transports.Kafka
File(s): /home/runner/work/AsyncResponse/AsyncResponse/src/Transports/AsyncResponse.Transports.Kafka/KafkaTransportOptionsValidator.cs
Line coverage
100%
Covered lines: 37
Uncovered lines: 0
Coverable lines: 37
Total lines: 64
Line coverage: 100%
Branch coverage
100%
Covered branches: 26
Total branches: 26
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Required(...)100%22100%
Positive(...)100%22100%
ValidateCommon(...)100%2222100%

File(s)

/home/runner/work/AsyncResponse/AsyncResponse/src/Transports/AsyncResponse.Transports.Kafka/KafkaTransportOptionsValidator.cs

#LineLine coverage
 1namespace AsyncResponse.Transports.Kafka;
 2
 3internal static class KafkaTransportOptionsValidator
 4{
 5    /// <summary>Validates the supplied options.</summary>
 6    public static string Required(string? value, string name)
 37        => !string.IsNullOrWhiteSpace(value)
 38            ? value
 39            : throw new InvalidOperationException($"{nameof(KafkaAsyncResponseTransportOptions)}.{name} must be configur
 10
 11    /// <summary>Validates the supplied options.</summary>
 12    public static void Positive(TimeSpan value, string name)
 13    {
 314        if (value <= TimeSpan.Zero)
 315            throw new InvalidOperationException($"{nameof(KafkaAsyncResponseTransportOptions)}.{name} must be positive."
 316    }
 17
 18    /// <summary>Validates the supplied options.</summary>
 19    public static void ValidateCommon(KafkaAsyncResponseTransportOptions options)
 20    {
 321        _ = Required(options.BootstrapServers, nameof(options.BootstrapServers));
 322        _ = Required(options.TopicPrefix, nameof(options.TopicPrefix));
 323        _ = Required(options.WorkerConsumerGroup, nameof(options.WorkerConsumerGroup));
 324        _ = Required(options.ResponseConsumerGroup, nameof(options.ResponseConsumerGroup));
 325        _ = Required(options.CorrelationIdHeader, nameof(options.CorrelationIdHeader));
 326        _ = Required(options.DefaultReplyTargetName, nameof(options.DefaultReplyTargetName));
 27
 328        if (options.DeadLetterEnabled && string.IsNullOrWhiteSpace(options.DeadLetterTopic))
 329            _ = Required(options.DeadLetterTopicSuffix, nameof(options.DeadLetterTopicSuffix));
 30
 331        Positive(options.OffsetCommitInterval, nameof(options.OffsetCommitInterval));
 332        Positive(options.OperationTimeout, nameof(options.OperationTimeout));
 333        Positive(options.PublishRetryBaseDelay, nameof(options.PublishRetryBaseDelay));
 334        Positive(options.PublishRetryMaxDelay, nameof(options.PublishRetryMaxDelay));
 335        Positive(options.SubscriberRetryBaseDelay, nameof(options.SubscriberRetryBaseDelay));
 336        Positive(options.SubscriberRetryMaxDelay, nameof(options.SubscriberRetryMaxDelay));
 37
 338        if (options.PublishMaxAttempts <= 0)
 339            throw new InvalidOperationException($"{nameof(KafkaAsyncResponseTransportOptions)}.{nameof(options.PublishMa
 40
 341        if (options.PublishRetryBaseDelay > options.PublishRetryMaxDelay)
 42        {
 343            throw new InvalidOperationException(
 344                $"{nameof(KafkaAsyncResponseTransportOptions)}.{nameof(options.PublishRetryBaseDelay)} cannot exceed " +
 345                $"{nameof(KafkaAsyncResponseTransportOptions)}.{nameof(options.PublishRetryMaxDelay)}.");
 46        }
 47
 348        if (options.SubscriberRetryBaseDelay > options.SubscriberRetryMaxDelay)
 49        {
 350            throw new InvalidOperationException(
 351                $"{nameof(KafkaAsyncResponseTransportOptions)}.{nameof(options.SubscriberRetryBaseDelay)} cannot exceed 
 352                $"{nameof(KafkaAsyncResponseTransportOptions)}.{nameof(options.SubscriberRetryMaxDelay)}.");
 53        }
 54
 355        if (options.TopicNumPartitions is not -1 and <= 0)
 356            throw new InvalidOperationException($"{nameof(KafkaAsyncResponseTransportOptions)}.{nameof(options.TopicNumP
 57
 358        if (options.TopicReplicationFactor is not (-1) and <= 0)
 359            throw new InvalidOperationException($"{nameof(KafkaAsyncResponseTransportOptions)}.{nameof(options.TopicRepl
 60
 361        if (options.HostShutdownTimeout is { } hostShutdownTimeout && hostShutdownTimeout <= TimeSpan.Zero)
 362            throw new InvalidOperationException($"{nameof(KafkaAsyncResponseTransportOptions)}.{nameof(options.HostShutd
 363    }
 64}