public override async Task <IResponse> GetResponse(Http.Fetcher.IFetcher fetcher, IRequest request) { if (await ExecuteOnce(fetcher, request)) { return(response); } else { throw latestException; } }
protected async Task <bool> ExecuteOnce(Http.Fetcher.IFetcher fetcher, IRequest request) { try { response = await fetcher.ExecuteAsync(request); return(true); } catch (Http.Exception.HttpException ex) { latestException = ex; return(false); } }
public override async Task <IResponse> GetResponse(Http.Fetcher.IFetcher fetcher, IRequest request) { for (var i = 0; i < RetryCount; i++) { // give it a try if (await ExecuteOnce(fetcher, request)) { return(response); } // give it a break before another retry if (DelayMs > 0) { await Task.Delay(DelayMs); } } throw Http.Exception.NoRetriesLeftException.Factory(RetryCount, latestException); }
public abstract Task <IResponse> GetResponse(Http.Fetcher.IFetcher fetcher, IRequest request);