-
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a retry handler into the solution. We can now retry failed api …
- Loading branch information
TidusJar
committed
May 13, 2016
1 parent
f9205fc
commit adeeb78
Showing
5 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters