Exemple #1
0
 private static Async <Either <T, Exception> > DoRetry <T>(Async <T> m, Retry.Strategy s)
 {
     return(() => Async.Sleep((int)s.Delay())
            .Then(m)
            .Catch()
            .RunSynchronously()
            .From(
                Either.Success <T, Exception>,
                l =>
     {
         var next = s.Next();
         return next.Retries > 0
                     ? DoRetry(m, next)()
                     : Either.Failure <T, Exception>(l);
     }));
 }
Exemple #2
0
 public static Async <Either <T, Exception> > Retry <T>(this Async <T> m, Retry.Strategy s)
 {
     return(DoRetry(m, new Retry.Strategy(0, 0, 0, _ => 0, _ => s)));
 }
Exemple #3
0
 internal static Retry.Strategy OnDelay(this Retry.Strategy s, Func <Retry.Strategy, Func <Retry.Strategy, uint> > f)
 {
     return(new Retry.Strategy(s.Retries, s.Attempts, s.DelayBase, f(s), s.next));
 }