< Summary

Class:Azure.Messaging.EventHubs.EventHubsRetryOptions
Assembly:Azure.Messaging.EventHubs
File(s):C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.Messaging.EventHubs\src\EventHubsRetryOptions.cs
Covered lines:24
Uncovered lines:0
Coverable lines:24
Total lines:115
Line coverage:100% (24 of 24)
Covered branches:2
Total branches:2
Branch coverage:100% (2 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
get_Mode()-100%100%
get_MaximumRetries()-100%100%
set_MaximumRetries(...)-100%100%
get_Delay()-100%100%
set_Delay(...)-100%100%
get_MaximumDelay()-100%100%
set_MaximumDelay(...)-100%100%
get_TryTimeout()-100%100%
set_TryTimeout(...)-100%100%
get_CustomRetryPolicy()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\eventhub\Azure.Messaging.EventHubs\src\EventHubsRetryOptions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Diagnostics.CodeAnalysis;
 6using Azure.Core;
 7
 8namespace Azure.Messaging.EventHubs
 9{
 10    /// <summary>
 11    ///    The set of options that can be specified to influence how
 12    ///    retry attempts are made, and a failure is eligible to be retried.
 13    /// </summary>
 14    ///
 15    public class EventHubsRetryOptions
 16    {
 17        /// <summary>The maximum number of retry attempts before considering the associated operation to have failed.</s
 156018        private int _maximumRetries = 3;
 19
 20        /// <summary>The delay or back-off factor to apply between retry attempts.</summary>
 156021        private TimeSpan _delay = TimeSpan.FromSeconds(0.8);
 22
 23        /// <summary>The maximum delay to allow between retry attempts.</summary>
 156024        private TimeSpan _maximumDelay = TimeSpan.FromMinutes(1);
 25
 26        /// <summary>The maximum duration to wait for an operation, per attempt.</summary>
 156027        private TimeSpan _tryTimeout = TimeSpan.FromMinutes(1);
 28
 29        /// <summary>
 30        ///   The approach to use for calculating retry delays.
 31        /// </summary>
 32        ///
 281833        public EventHubsRetryMode Mode { get; set; } = EventHubsRetryMode.Exponential;
 34
 35        /// <summary>
 36        ///   The maximum number of retry attempts before considering the associated operation
 37        ///   to have failed.
 38        /// </summary>
 39        ///
 40        public int MaximumRetries
 41        {
 194642            get => _maximumRetries;
 43
 44            set
 45            {
 39446                Argument.AssertInRange(value, 0, 100, nameof(MaximumRetries));
 38247                _maximumRetries = value;
 38248            }
 49        }
 50
 51        /// <summary>
 52        ///   The delay between retry attempts for a fixed approach or the delay
 53        ///   on which to base calculations for a backoff-based approach.
 54        /// </summary>
 55        ///
 56        public TimeSpan Delay
 57        {
 286258            get => _delay;
 59
 60            set
 61            {
 35862                Argument.AssertInRange(value, TimeSpan.FromMilliseconds(1), TimeSpan.FromMinutes(5), nameof(Delay));
 34463                _delay = value;
 34464            }
 65        }
 66
 67        /// <summary>
 68        ///   The maximum permissible delay between retry attempts.
 69        /// </summary>
 70        ///
 71        public TimeSpan MaximumDelay
 72        {
 174073            get => _maximumDelay;
 74
 75            set
 76            {
 38077                Argument.AssertNotNegative(value, nameof(MaximumDelay));
 37478                _maximumDelay = value;
 37479            }
 80        }
 81
 82        /// <summary>
 83        ///   The maximum duration to wait for completion of a single attempt, whether the initial
 84        ///   attempt or a retry.
 85        /// </summary>
 86        ///
 87        [SuppressMessage("Usage", "CA2208:Instantiate argument exceptions correctly", Justification = "We believe using 
 88        public TimeSpan TryTimeout
 89        {
 49690            get => _tryTimeout;
 91
 92            set
 93            {
 24294                if (value < TimeSpan.Zero)
 95                {
 696                    throw new ArgumentException(Resources.TimeoutMustBePositive, nameof(TryTimeout));
 97                }
 98
 23699                Argument.AssertInRange(value, TimeSpan.Zero, TimeSpan.FromHours(1), nameof(TryTimeout));
 230100                _tryTimeout = value;
 230101            }
 102        }
 103
 104        /// <summary>
 105        ///   A custom retry policy to be used in place of the individual option values.
 106        /// </summary>
 107        ///
 108        /// <remarks>
 109        ///   When populated, this custom policy will take precedence over the individual retry
 110        ///   options provided.
 111        /// </remarks>
 112        ///
 1116113        public EventHubsRetryPolicy CustomRetryPolicy { get; set; }
 114    }
 115}