Skip to content

Instantly share code, notes, and snippets.

@marraia
Last active July 27, 2018 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marraia/832f77c67dbd2185d4b597edaea48fc1 to your computer and use it in GitHub Desktop.
Save marraia/832f77c67dbd2185d4b597edaea48fc1 to your computer and use it in GitHub Desktop.
private RetryPolicy WaitRetryPolicyPolly()
{
return Policy.Handle<HttpRequestException>()
.WaitAndRetry(
//Quantidade de vezes de re-tentativas
3,
//Tempo de espera para a próxima requisição
retryAttempt => TimeSpan.FromSeconds(30),
(exception, timeSpan, retryCount, context) =>
{
var msg = $"Retry {retryCount} implemented with Pollys RetryPolicy " +
$"of {context.PolicyKey} " +
$"at {context.ExecutionKey}, " +
$"due to: {exception}.";
_log.LogWarning(msg);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment