Added a retry handler into the solution. We can now retry failed api requests.

this should resolve #202 and start on #208
This commit is contained in:
TidusJar 2016-05-12 22:39:21 -04:00
parent f9205fc027
commit adeeb7824d
5 changed files with 90 additions and 8 deletions

View file

@ -0,0 +1,34 @@
using System;
using Polly.Retry;
using Polly;
namespace PlexRequests.Api
{
public static class RetryHandler
{
public static RetryPolicy RetryAndWaitPolicy(TimeSpan[] TimeSpan, Action action)
{
var policy = Policy.Handle<Exception> ()
.WaitAndRetry(TimeSpan, (exception, timeSpan) => action());
return policy;
}
public static RetryPolicy RetryAndWaitPolicy(TimeSpan[] TimeSpan)
{
var policy = Policy.Handle<Exception> ()
.WaitAndRetry(TimeSpan);
return policy;
}
public static RetryPolicy RetryAndWaitPolicy(TimeSpan[] TimeSpan, Action<Exception, TimeSpan> action)
{
var policy = Policy.Handle<Exception> ()
.WaitAndRetry(TimeSpan, (exception, timeSpan) => action(exception, timeSpan));
return policy;
}
}
}