mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 11:38:32 -07:00
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:
parent
f9205fc027
commit
adeeb7824d
5 changed files with 90 additions and 8 deletions
34
PlexRequests.Api/RetryHandler.cs
Normal file
34
PlexRequests.Api/RetryHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue