コード例 #1
0
        /// <summary>
        /// Create an exponential backoff retry policy given a detection strategy.
        /// </summary>
        /// <param name="strategy"></param>
        /// <returns></returns>
        private static RetryPolicy Exponential(ITransientErrorDetectionStrategy strategy, int retryCount)
        {
            if (retryCount == 0)
                return RetryPolicy.NoRetry;

            if (retryCount == 1)
            {
                var retryPolicy = new RetryPolicy(strategy, 1);
                retryPolicy.RetryStrategy.FastFirstRetry = true;

                return retryPolicy;
            }

            var minBackoff = TimeSpan.FromSeconds(1);
            var maxBackoff = TimeSpan.FromSeconds(10);
            var deltaBackoff = TimeSpan.FromSeconds(5);

            // if retryCount is equal to Int16.MaxValue (32767)
            // then increase the backoff intervals.
            if (retryCount == Int16.MaxValue)
            {
                minBackoff = TimeSpan.FromSeconds(1);
                maxBackoff = TimeSpan.FromSeconds(300);
                deltaBackoff = TimeSpan.FromSeconds(10);
            }

            // 30 60 120 240

            var exponentialBackoff = new ExponentialBackoff(retryCount, minBackoff, maxBackoff, deltaBackoff);

            return new RetryPolicy(strategy, exponentialBackoff);
        }
コード例 #2
0
 public UpdateSessionManagerRetryDecorator(IUpdateSessionManager updateSessionManager,
     RetryStrategy retryStrategy,
     ITransientErrorDetectionStrategy errorDetectionStrategy)
 {
     _updateSessionManager = updateSessionManager;
     _retryPolicy = new RetryPolicy(errorDetectionStrategy, retryStrategy);
 }
コード例 #3
0
        private static RetryPolicy Exponential(ITransientErrorDetectionStrategy strategy)
        {
            var retryCount = 3;
            var minBackoff = TimeSpan.FromSeconds(1);
            var maxBackoff = TimeSpan.FromSeconds(10);
            var deltaBackoff = TimeSpan.FromSeconds(5);

            var exponentialBackoff = new ExponentialBackoff(retryCount, minBackoff, maxBackoff, deltaBackoff);

            return new RetryPolicy(strategy, exponentialBackoff);
        }
コード例 #4
0
        private static RetryPolicy Exponential(ITransientErrorDetectionStrategy strategy,
                                                int retryCount,
                                                double maxBackoffDelayInSeconds,
                                                double delta)
        {
            var maxBackoff = TimeSpan.FromSeconds(maxBackoffDelayInSeconds);
            var deltaBackoff = TimeSpan.FromSeconds(delta);
            var minBackoff = TimeSpan.FromSeconds(0);

            var exponentialBackoff = new ExponentialBackoff(retryCount, minBackoff, maxBackoff, deltaBackoff);

            return new RetryPolicy(strategy, exponentialBackoff);
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:GlebTeterin.ReliableSql.ReliableSqlConnection"/> class with the specified number of retry attempts and backoff parameters for calculating the exponential delay between retries.
 /// </summary>
 public ReliableSqlConnection(string connectionString, ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff)
     : this(connectionString, new SmartRetryPolicy(errorDetectionStrategy, retryCount, minBackoff, maxBackoff, deltaBackoff))
 {
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:GlebTeterin.ReliableSql.ReliableSqlConnection"/> class with the specified number of retry attempts and default fixed time interval between retries.
 /// </summary>
 public ReliableSqlConnection(string connectionString, ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount)
     : this(connectionString, new SmartRetryPolicy(errorDetectionStrategy, retryCount))
 {
 }
コード例 #7
0
 private static RetryPolicy Exponential(ITransientErrorDetectionStrategy strategy, int count)
 {
     return Exponential(strategy, count, 1024d, 2d);
 }
コード例 #8
0
        public static RetryPolicy GetPolicy(ITransientErrorDetectionStrategy strategy, int retryCount)
        {
            RetryPolicy policy = new RetryPolicy(strategy, retryCount, TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(50));

            return policy;
        }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Microsoft.Azure.WebJobs.Extensions.EdgeHub.RetryPolicy" /> class with the specified number of retry attempts and parameters defining the progressive delay between retries.
 /// </summary>
 /// <param name="errorDetectionStrategy">The <see cref="T:Microsoft.Azure.WebJobs.Extensions.EdgeHub.ITransientErrorDetectionStrategy" /> that is responsible for detecting transient conditions.</param>
 /// <param name="retryCount">The number of retry attempts.</param>
 /// <param name="initialInterval">The initial interval that will apply for the first retry.</param>
 /// <param name="increment">The incremental time value that will be used to calculate the progressive delay between retries.</param>
 public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan initialInterval, TimeSpan increment) : this(errorDetectionStrategy, new Incremental(retryCount, initialInterval, increment))
 {
 }
コード例 #10
0
ファイル: RetryAttribute.cs プロジェクト: ctguxp/Waffle
 /// <summary>
 /// Initializes a new instance of the <see cref="RetryAttribute"/> class with the specified number of retry attempts and backOff parameters for calculating the exponential delay between retries.
 /// </summary>
 /// <param name="errorDetectionStrategy">The <see cref="ITransientErrorDetectionStrategy" /> that is responsible for detecting transient conditions.</param>
 /// <param name="retryCount">The number of retry attempts.</param>
 /// <param name="minBackOff">The minimum backOff time. In milliseconds.</param>
 /// <param name="maxBackOff">The maximum backOff time. In milliseconds.</param>
 /// <param name="deltaBackOff">The time value that will be used to calculate a random delta in the exponential delay between retries. In milliseconds.</param>
 public RetryAttribute(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, double minBackOff, double maxBackOff, double deltaBackOff) :
     this(new RetryPolicy(errorDetectionStrategy, retryCount, TimeSpan.FromMilliseconds(minBackOff), TimeSpan.FromMilliseconds(maxBackOff), TimeSpan.FromMilliseconds(deltaBackOff)))
 {
 }
コード例 #11
0
ファイル: RetryAttribute.cs プロジェクト: ctguxp/Waffle
 /// <summary>
 /// Initializes a new instance of the <see cref="RetryAttribute"/> class with the specified number of retry attempts and fixed time interval between retries.
 /// </summary>        
 /// <param name="errorDetectionStrategy">The <see cref="ITransientErrorDetectionStrategy" /> that is responsible for detecting transient conditions.</param>
 /// <param name="retryCount">The number of retry attempts.</param>
 /// <param name="retryInterval">The interval between retries. In milliseconds.</param>
 public RetryAttribute(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, double retryInterval) :
     this(new RetryPolicy(errorDetectionStrategy, retryCount, TimeSpan.FromMilliseconds(retryInterval)))
 {
 }
コード例 #12
0
ファイル: RetryAttribute.cs プロジェクト: ctguxp/Waffle
 /// <summary>
 /// Initializes a new instance of the <see cref="RetryAttribute"/> class with the specified number of retry attempts.
 /// </summary>
 /// <param name="errorDetectionStrategy">The <see cref="ITransientErrorDetectionStrategy" /> that is responsible for detecting transient conditions.</param>
 /// <param name="retryCount">The number of retry attempts.</param>
 public RetryAttribute(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount) :
     this(new RetryPolicy(errorDetectionStrategy, retryCount))
 {
 }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Microsoft.Azure.Devices.Edge.Util.TransientFaultHandling.RetryPolicy" /> class with the specified number of retry attempts and fixed time interval between retries.
 /// </summary>
 /// <param name="errorDetectionStrategy">The <see cref="T:Microsoft.Azure.Devices.Edge.Util.TransientFaultHandling.ITransientErrorDetectionStrategy" /> that is responsible for detecting transient conditions.</param>
 /// <param name="retryCount">The number of retry attempts.</param>
 /// <param name="retryInterval">The interval between retries.</param>
 public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan retryInterval)
     : this(errorDetectionStrategy, new FixedInterval(retryCount, retryInterval))
 {
 }
コード例 #14
0
ファイル: TestExecutor.cs プロジェクト: G-Rad/reliable-sql
 public TestExecutor(string connectionString, ITransientErrorDetectionStrategy errorDetectionStrategy, RetryStrategy retryStrategy)
 {
     _connectionManager = new ConnectionManager(connectionString, errorDetectionStrategy, retryStrategy);
 }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:GlebTeterin.ReliableSql.ReliableSqlConnection"/> class with the specified number of retry attempts and parameters defining the progressive delay between retries.
 /// </summary>
 public ReliableSqlConnection(string connectionString, ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan initialInterval, TimeSpan increment)
     : this(connectionString, new SmartRetryPolicy(errorDetectionStrategy, retryCount, initialInterval, increment))
 {
 }
コード例 #16
0
        private static RetryPolicy Exponential(
            ITransientErrorDetectionStrategy strategy,
            int retryCount = 3,
            double maxBackoffDelayInSeconds = 1024,
            double delta = 2)
        {
            var exponentialBackoff = new ExponentialBackoff(retryCount,
                TimeSpan.FromSeconds(0),
                TimeSpan.FromSeconds(maxBackoffDelayInSeconds),
                TimeSpan.FromSeconds(delta));

            return new RetryPolicy(strategy,
                exponentialBackoff);
        }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:GlebTeterin.ReliableSql.ConnectionManager"/> class with a connection string and a <see cref="P:GlebTeterin.ReliableSql.AzureSqlStrategy"/>.
 /// </summary>
 public ConnectionManager(string connectionString, ITransientErrorDetectionStrategy errorDetectionStrategy, RetryStrategy retryStrategy)
     : this(connectionString, new SmartRetryPolicy(errorDetectionStrategy, retryStrategy))
 {
 }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:GlebTeterin.ReliableSql.ConnectionManager"/> class with the specified number of retry attempts and fixed time interval between retries.
 /// </summary>
 public ConnectionManager(string connectionString, ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan retryInterval)
     : this(connectionString, new SmartRetryPolicy(errorDetectionStrategy, retryCount, retryInterval))
 {
 }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Microsoft.Azure.WebJobs.Extensions.EdgeHub.RetryPolicy" /> class with the specified number of retry attempts and backoff parameters for calculating the exponential delay between retries.
 /// </summary>
 /// <param name="errorDetectionStrategy">The <see cref="T:Microsoft.Azure.WebJobs.Extensions.EdgeHub.ITransientErrorDetectionStrategy" /> that is responsible for detecting transient conditions.</param>
 /// <param name="retryCount">The number of retry attempts.</param>
 /// <param name="minBackoff">The minimum backoff time.</param>
 /// <param name="maxBackoff">The maximum backoff time.</param>
 /// <param name="deltaBackoff">The time value that will be used to calculate a random delta in the exponential delay between retries.</param>
 public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff) : this(errorDetectionStrategy, new ExponentialBackoff(retryCount, minBackoff, maxBackoff, deltaBackoff))
 {
 }