Ejemplo n.º 1
0
        static ShouldRetry RetryAlwaysImplementation()
        {
            var should = new ShouldRetry((int number, Exception exc, out TimeSpan delay) =>
            {
                delay = TimeSpan.FromMinutes(2);
                return true;
            });

            return should;
        }
Ejemplo n.º 2
0
        static ShouldRetry RetryAlwaysImplementation()
        {
            var should = new ShouldRetry((int number, Exception exc, out TimeSpan delay) =>
            {
                delay = TimeSpan.FromMinutes(2);
                Console.WriteLine("Error: " + exc.Message);
                Console.WriteLine("Retrying in {0} minutes", delay.Minutes);
                return true;
            });

            return should;
        }
 public ShouldRetryWrapper(RetryPolicy retryPolicy)
 {
     _retryPolicy = retryPolicy;
     _shouldRetry = _retryPolicy.RetryStrategy.GetShouldRetry();
 }
Ejemplo n.º 4
0
 protected override void Act()
 {
     this.retryStrategy = new Incremental();
     this.shouldRetry = this.retryStrategy.GetShouldRetry();
 }
Ejemplo n.º 5
0
 protected override void Act()
 {
     this.retryStrategy = new Incremental("name", 5, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(2));
     this.shouldRetry = this.retryStrategy.GetShouldRetry();
 }
 public ShouldRetryWrapper(ShouldRetry shouldRetry)
 {
     this.shouldRetry = shouldRetry;
 }
Ejemplo n.º 7
0
        /// <remarks>Policy must support exceptions being null.</remarks>
        static Exception DoUntilTrue(ShouldRetry retryPolicy, CancellationToken token, Func<bool> action)
        {
            var retryCount = 0;

            while (true)
            {
                token.ThrowIfCancellationRequested();
                try
                {
                    if (action())
                    {
                        return null;
                    }

                    TimeSpan delay;
                    if (retryPolicy(retryCount, null, out delay))
                    {
                        retryCount++;
                        if (delay > TimeSpan.Zero)
                        {
                            token.WaitHandle.WaitOne(delay);
                        }

                        continue;
                    }

                    return new TimeoutException("Failed to reach a successful result in a limited number of retrials");
                }
                catch (Exception e)
                {
                    TimeSpan delay;
                    if (retryPolicy(retryCount, e, out delay))
                    {
                        retryCount++;
                        if (delay > TimeSpan.Zero)
                        {
                            token.WaitHandle.WaitOne(delay);
                        }

                        continue;
                    }

                    return e;
                }
            }
        }
 protected override void Act()
 {
     this.retryStrategy = new ExponentialBackoff("name", 5, TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(10));
     this.shouldRetry   = this.retryStrategy.GetShouldRetry();
 }
Ejemplo n.º 9
0
 protected override void Act()
 {
     this.retryStrategy = new FixedInterval("name", 5, TimeSpan.FromSeconds(5));
     this.shouldRetry = this.retryStrategy.GetShouldRetry();
 }
Ejemplo n.º 10
0
 protected override void Act()
 {
     this.retryStrategy = new FixedInterval(5);
     this.shouldRetry   = this.retryStrategy.GetShouldRetry();
 }
 public IotHubRuntimeOperationRetryStrategy(int retryCount)
     : base(null, false)
 {
     this.defaultRetryStrategy    = new ExponentialBackoff(retryCount, TimeSpan.FromMilliseconds(100), TimeSpan.FromSeconds(10), TimeSpan.FromMilliseconds(100)).GetShouldRetry();
     this.throttlingRetryStrategy = new ExponentialBackoff(retryCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(5)).GetShouldRetry();
 }
Ejemplo n.º 12
0
 public AsyncExecution(Func <Task> taskAction, ShouldRetry shouldRetry, Func <Exception, bool> isTransient, Action <int, Exception, TimeSpan> onRetrying, bool fastFirstRetry, CancellationToken cancellationToken) :
     base(() => StartAsGenericTask(taskAction), shouldRetry, isTransient, onRetrying, fastFirstRetry, cancellationToken)
 {
 }
 protected override void Act()
 {
     this.retryStrategy = new ExponentialBackoff();
     this.shouldRetry   = this.retryStrategy.GetShouldRetry();
 }
 protected override void Act()
 {
     this.retryStrategy = new ExponentialBackoff("name", 5, TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(10));
     this.shouldRetry = this.retryStrategy.GetShouldRetry();
 }
Ejemplo n.º 15
0
 protected override void Act()
 {
     this.retryStrategy = new FixedInterval(5);
     this.shouldRetry = this.retryStrategy.GetShouldRetry();
 }
 protected override void Act()
 {
     this.retryStrategy = new ExponentialBackoff();
     this.shouldRetry = this.retryStrategy.GetShouldRetry();
 }
 public IotHubRuntimeOperationRetryStrategy(RetryStrategy retryStrategy)
     : base(null, false)
 {
     this.retryStrategy           = retryStrategy;
     this.throttlingRetryStrategy = new ExponentialBackoff(RetryCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(5)).GetShouldRetry();
 }