Ejemplo n.º 1
0
        /// <summary>
        /// Returns the default retry policy dedicated to handling transient conditions with SQL connections.
        /// </summary>
        /// <returns>The retry policy for SQL connections with the corresponding default strategy (or the default strategy, if no retry strategy for SQL connections was found).</returns>
        public static RetryPolicy GetDefaultSqlConnectionRetryPolicy(this RetryManager retryManager)
        {
            if (retryManager == null)
            {
                throw new ArgumentNullException("retryManager");
            }

            return(new RetryPolicy(new SqlDatabaseTransientErrorDetectionStrategy(), retryManager.GetDefaultSqlConnectionRetryStrategy()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the default retry strategy for SQL commands.
        /// </summary>
        /// <returns>The default retry strategy for SQL commands (or the default strategy, if no default could be found).</returns>
        public static RetryStrategy GetDefaultSqlCommandRetryStrategy(this RetryManager retryManager)
        {
            if (retryManager == null)
            {
                throw new ArgumentNullException("retryManager");
            }

            return(retryManager.GetDefaultRetryStrategy(DefaultStrategyCommandTechnologyName));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the specified retry manager as the default retry manager.
        /// </summary>
        /// <param name="retryManager">The retry manager.</param>
        /// <param name="throwIfSet">true to throw an exception if the manager is already set; otherwise, false. Defaults to <see langword="true"/>.</param>
        /// <exception cref="InvalidOperationException">The singleton is already set and <paramref name="throwIfSet"/> is true.</exception>
        public static void SetDefault(RetryManager retryManager, bool throwIfSet = true)
        {
            if (defaultRetryManager != null && throwIfSet && retryManager != defaultRetryManager)
            {
                throw new InvalidOperationException(Resources.ExceptionRetryManagerAlreadySet);
            }

            defaultRetryManager = retryManager;
        }
        /// <summary>
        /// Returns the default retry policy dedicated to handling transient conditions with Windows Azure Service Bus.
        /// </summary>
        /// <returns>The retry policy for Windows Azure Service Bus with the corresponding default strategy (or the default strategy if no retry strategy definition for Windows Azure Service Bus was found).</returns>
        public static RetryPolicy GetDefaultAzureServiceBusRetryPolicy(this RetryManager retryManager)
        {
            if (retryManager == null)
            {
                throw new ArgumentNullException("retryManager");
            }

            return(new RetryPolicy(new ServiceBusTransientErrorDetectionStrategy(), retryManager.GetDefaultAzureServiceBusRetryStrategy()));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a retry manager from the system configuration.
 /// </summary>
 /// <returns></returns>
 public static RetryManager CreateDefault()
 {
     using (var source = new SystemConfigurationSource())
     {
         var settings = RetryPolicyConfigurationSettings.GetRetryPolicySettings(source);
         var manager  = settings.BuildRetryManager();
         RetryManager.SetDefault(manager);
         return(manager);
     }
 }
        /// <summary>
        /// Creates a retry manager from the system configuration.
        /// </summary>
        /// <returns></returns>
        public static RetryManager CreateDefault(
            string configurationFile = RetryConfiguration.DefaultConfigurationFile, string configurationKey = nameof(RetryManager), Func <IConfigurationSection, RetryStrategy>?getCustomRetryStrategy = null)
        {
            Argument.NotNullOrEmpty(configurationFile, nameof(configurationFile));
            Argument.NotNullOrEmpty(configurationKey, nameof(configurationKey));

            RetryManager manager = RetryConfiguration.GetRetryManager(configurationFile, configurationKey, getCustomRetryStrategy);

            RetryManager.SetDefault(manager);
            return(manager);
        }
        /// <summary>
        /// Returns the default retry strategy for SQL connections.
        /// </summary>
        /// <returns>The default retry strategy for SQL connections (or the default strategy, if no default could be found).</returns>
        public static RetryStrategy GetDefaultSqlConnectionRetryStrategy(this RetryManager retryManager)
        {
            Argument.NotNull(retryManager, nameof(retryManager));

            try
            {
                return(retryManager.GetDefaultRetryStrategy(DefaultStrategyConnectionTechnologyName));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(retryManager.GetDefaultRetryStrategy(DefaultStrategyCommandTechnologyName));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Returns the default retry strategy for SQL connections.
        /// </summary>
        /// <returns>The default retry strategy for SQL connections (or the default strategy, if no default could be found).</returns>
        public static RetryStrategy GetDefaultSqlConnectionRetryStrategy(this RetryManager retryManager)
        {
            if (retryManager == null)
            {
                throw new ArgumentNullException("retryManager");
            }

            try
            {
                return(retryManager.GetDefaultRetryStrategy(DefaultStrategyConnectionTechnologyName));
            }
            catch (ArgumentOutOfRangeException)
            {
                return(retryManager.GetDefaultRetryStrategy(DefaultStrategyCommandTechnologyName));
            }
        }
 /// <summary>
 /// Sets the retry manager.
 /// </summary>
 /// <param name="retryManager">The retry manager.</param>
 /// <param name="throwIfSet">true to throw an exception if the writer is already set; otherwise, false. Defaults to <see langword="true"/>.</param>
 /// <exception cref="InvalidOperationException">The factory is already set and <paramref name="throwIfSet"/> is true.</exception>
 public static void SetRetryManager(RetryManager?retryManager, bool throwIfSet = true)
 {
     RetryManager.SetDefault(retryManager, throwIfSet);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Returns the default retry policy dedicated to handling transient conditions with Windows Azure Caching.
        /// </summary>
        /// <returns>The retry policy for Windows Azure Caching with the corresponding default strategy (or the default strategy if no retry strategy definition for Windows Azure Caching was found).</returns>
        public static RetryPolicy GetDefaultCachingRetryPolicy(this RetryManager retryManager)
        {
            Argument.NotNull(retryManager, nameof(retryManager));

            return(new RetryPolicy(new CacheTransientErrorDetectionStrategy(), retryManager.GetDefaultCachingRetryStrategy()));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Returns the default retry strategy for Windows Azure Caching.
        /// </summary>
        /// <returns>The default Windows Azure Caching retry strategy (or the default strategy if no default could be found for Windows Azure Caching).</returns>
        public static RetryStrategy GetDefaultCachingRetryStrategy(this RetryManager retryManager)
        {
            Argument.NotNull(retryManager, nameof(retryManager));

            return(retryManager.GetDefaultRetryStrategy(DefaultStrategyTechnologyName));
        }
        /// <summary>
        /// Returns the default retry policy dedicated to handling transient conditions with SQL connections.
        /// </summary>
        /// <returns>The retry policy for SQL connections with the corresponding default strategy (or the default strategy, if no retry strategy for SQL connections was found).</returns>
        public static RetryPolicy GetDefaultSqlConnectionRetryPolicy(this RetryManager retryManager)
        {
            Argument.NotNull(retryManager, nameof(retryManager));

            return(new RetryPolicy(new SqlDatabaseTransientErrorDetectionStrategy(), retryManager.GetDefaultSqlConnectionRetryStrategy()));
        }