public static Task RetryOnTransientErrorAsync(this IDbFactory factory, CancellationToken token, Func <IWithSqlAsync, Task> action) { return(ModelTools.RetryOnException <DbException>(async() => { using (var db = await factory.CreateAsync(token).ConfigureAwait(false)) { var op = new ResilientWithSql(db, token); await action(op).ConfigureAwait(false); } }, x => { if (factory.Provider.IsDbBusy(x)) { return OnExceptionAction.IgnoreAndContinue; } return OnExceptionAction.Throw; }, SqlFuManager.Config.TransientErrors.Tries, SqlFuManager.Config.TransientErrors.Wait)); }
public static void RetryOnTransientError(this IDbFactory factory, Action <IWithSql> action) { ModelTools.RetryOnException <DbException>(() => { using (var db = factory.Create()) { var op = new ResilientWithSql(db, CancellationToken.None); action(op); } }, x => { if (factory.Provider.IsDbBusy(x)) { return(OnExceptionAction.IgnoreAndContinue); } return(OnExceptionAction.Throw); }, SqlFuManager.Config.TransientErrors.Tries, SqlFuManager.Config.TransientErrors.Wait); }