Created
April 28, 2017 13:34
-
-
Save johnib/c642c2f71c0ae08305cacddf22163217 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var someClassInstance = new SomeClass(); | |
someClassInstance.DoSomething(); | |
} | |
} | |
class Retry : Attribute | |
{ | |
private static readonly Policy DefaultRetryPolicy = Policy | |
.Handle<Exception>() | |
.WaitAndRetry(3, retryAttempt => TimeSpan.FromSeconds(5)); | |
public void Wrapper(Action action) | |
{ | |
DefaultRetryPolicy.Execute(action); | |
} | |
} | |
class SomeClass | |
{ | |
[Retry] | |
public void DoSomething() | |
{ | |
// core logic | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment