public SqlRetryLogic(int numberOfTries,
                             SqlRetryIntervalBaseEnumerator enumerator,
                             Predicate <Exception> transientPredicate,
                             Predicate <string> preCondition)
        {
            Debug.Assert(enumerator != null, $"The '{nameof(enumerator)}' mustn't be null.");
            Debug.Assert(transientPredicate != null, $"The '{nameof(transientPredicate)}' mustn't be null.");

            if (!(numberOfTries > counterDefaultValue && numberOfTries <= maxAttempts))
            {
                // The 'numberOfTries' should be between 1 and 60.
                throw SqlReliabilityUtil.ArgumentOutOfRange(nameof(numberOfTries), numberOfTries, counterDefaultValue + 1, maxAttempts);
            }

            NumberOfTries           = numberOfTries;
            RetryIntervalEnumerator = enumerator;
            TransientPredicate      = transientPredicate;
            PreCondition            = preCondition;
            Current = counterDefaultValue;
        }
Esempio n. 2
0
        private static SqlRetryLogicBaseProvider InternalCreateRetryProvider(SqlRetryLogicOption retryLogicOption, SqlRetryIntervalBaseEnumerator enumerator)
        {
            Debug.Assert(enumerator != null, $"The '{nameof(enumerator)}' mustn't be null.");

            if (retryLogicOption == null)
            {
                throw new ArgumentNullException(nameof(retryLogicOption));
            }

            var retryLogic = new SqlRetryLogic(retryLogicOption.NumberOfTries, enumerator,
                                               (e) => TransientErrorsCondition(e, retryLogicOption.TransientErrors ?? s_defaultTransientErrors),
                                               retryLogicOption.AuthorizedSqlCondition);

            return(new SqlRetryLogicProvider(retryLogic));
        }
 public SqlRetryLogic(SqlRetryIntervalBaseEnumerator enumerator, Predicate <Exception> transientPredicate)
     : this(counterDefaultValue + 1, enumerator, transientPredicate)
 {
 }
 public SqlRetryLogic(int numberOfTries, SqlRetryIntervalBaseEnumerator enumerator, Predicate <Exception> transientPredicate)
     : this(numberOfTries, enumerator, transientPredicate, null)
 {
 }