示例#1
0
        /// <summary>
        /// Constructs the retry policy to handle a multiple exception types as transient.
        /// </summary>
        /// <param name="exceptionTypes">The exception type to be considered to be transient.</param>
        /// <param name="maxAttempts">Optionally specifies the maximum number of times an action should be retried (defaults to <b>5</b>).</param>
        /// <param name="retryInterval">Optionally specifies the time interval between retry attempts (defaults to <b>1 second</b>).</param>
        /// <param name="timeout">Optionally specifies the maximum time the operation will be retried (defaults to unconstrained)</param>
        /// <param name="sourceModule">Optionally enables transient error logging by identifying the source module (defaults to <c>null</c>).</param>
        public LinearRetryPolicy(Type[] exceptionTypes, int maxAttempts = 5, TimeSpan?retryInterval = null, TimeSpan?timeout = null, string sourceModule = null)
            : this
            (
                e =>
        {
            if (exceptionTypes == null)
            {
                return(false);
            }

            foreach (var type in exceptionTypes)
            {
                if (TransientDetector.MatchException(e, type))
                {
                    return(true);
                }
            }

            return(false);
        },
                maxAttempts,
                retryInterval,
                timeout,
                sourceModule
            )
        {
        }
示例#2
0
 /// <summary>
 /// Constructs the retry policy to handle a specific exception type as transient.
 /// </summary>
 /// <param name="exceptionType">The exception type to be considered to be transient.</param>
 /// <param name="maxAttempts">Optionally specifies the maximum number of times an action should be retried (defaults to <b>5</b>).</param>
 /// <param name="retryInterval">Optionally specifies the time interval between retry attempts (defaults to <b>1 second</b>).</param>
 /// <param name="sourceModule">Optionally enables transient error logging by identifying the source module (defaults to <c>null</c>).</param>
 public LinearRetryPolicy(Type exceptionType, int maxAttempts = 5, TimeSpan?retryInterval = null, string sourceModule = null)
     : this
     (
         e => TransientDetector.MatchException(e, exceptionType),
         maxAttempts,
         retryInterval,
         sourceModule
     )
 {
     Covenant.Requires <ArgumentNullException>(exceptionType != null);
 }
示例#3
0
 /// <summary>
 /// Constructs the retry policy to handle a specific exception type as transient.
 /// </summary>
 /// <param name="exceptionType">The exception type to be considered to be transient.</param>
 /// <param name="maxAttempts">Optionally specifies the maximum number of times an action should be retried (defaults to <b>5</b>).</param>
 /// <param name="initialRetryInterval">Optionally specifies the initial retry interval between retry attempts (defaults to <b>1 second</b>).</param>
 /// <param name="maxRetryInterval">Optionally specifies the maximum retry interval (defaults to essentially unlimited: 24 hours).</param>
 /// <param name="timeout">Optionally specifies the maximum time the operation will be retried (defaults to unconstrained)</param>
 /// <param name="sourceModule">Optionally enables transient error logging by identifying the source module (defaults to <c>null</c>).</param>
 public ExponentialRetryPolicy(Type exceptionType, int maxAttempts = 5, TimeSpan?initialRetryInterval = null, TimeSpan?maxRetryInterval = null, TimeSpan?timeout = null, string sourceModule = null)
     : this
     (
         e => TransientDetector.MatchException(e, exceptionType),
         maxAttempts,
         initialRetryInterval,
         maxRetryInterval,
         timeout,
         sourceModule
     )
 {
     Covenant.Requires <ArgumentNullException>(exceptionType != null, nameof(exceptionType));
 }