You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
815 B

using Serilog;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
namespace EShopOnAbp.Shared.Hosting.Microservices.DbMigrations;
public abstract class PendingMigrationsCheckerBase : ITransientDependency
{
public async Task TryAsync(Func<Task> task, int retryCount = 3)
{
try
{
await task();
}
catch (Exception ex)
{
retryCount--;
if (retryCount <= 0)
{
throw;
}
Log.Warning($"{ex.GetType().Name} has been thrown. The operation will be tried {retryCount} times more. Exception:\n{ex.Message}");
await Task.Delay(RandomHelper.GetRandom(5000, 15000));
await TryAsync(task, retryCount);
}
}
}