Updated polly policy in WebHostExtensions

This commit is contained in:
Sumit Ghosh 2020-08-24 15:07:11 +05:30
parent c10b4ac934
commit 5bf33b26fb

View File

@ -40,13 +40,16 @@ namespace Catalog.API.Extensions
} }
else else
{ {
//var retry = Policy.Handle<SqlException>()
// .WaitAndRetry(new TimeSpan[]
// {
// TimeSpan.FromSeconds(3),
// TimeSpan.FromSeconds(5),
// TimeSpan.FromSeconds(8),
// });
var retry = Policy.Handle<SqlException>() var retry = Policy.Handle<SqlException>()
.WaitAndRetry(new TimeSpan[] .WaitAndRetry(10, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
{
TimeSpan.FromSeconds(3),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(8),
});
//if the sql server container is not created on run docker compose this //if the sql server container is not created on run docker compose this
//migration can't fail for network related exception. The retry options for DbContext only //migration can't fail for network related exception. The retry options for DbContext only