private async Task <string> SendWithRetryPolicy(SesRequest request, RetryPolicy retryPolicy) { var retryCount = 0; Exception lastException; do { if (retryCount > 0) { await Task.Delay(retryPolicy.GetDelay(retryCount)).ConfigureAwait(false); } try { return(await Send(request).ConfigureAwait(false)); } catch (SesException ex) when(ex.IsTransient) { lastException = ex; } retryCount++; }while (retryPolicy.ShouldRetry(retryCount)); throw lastException; }
public async Task <GetSendQuotaResult> GetSendQuotaAsync(SesEmail message) { var request = new SesRequest("GetSendQuota"); var text = await Send(request).ConfigureAwait(false); return(GetSendQuotaResponse.Parse(text).GetSendQuotaResult); }
private Task <string> Send(SesRequest request) { request.Parameters.Add("Version", Version); var httpRequest = new HttpRequestMessage(HttpMethod.Post, Endpoint) { Content = new FormUrlEncodedContent(request.Parameters) }; return(base.SendAsync(httpRequest)); }
public async Task <SendEmailResult> SendEmailAsync(SesEmail message) { var request = new SesRequest("SendEmail"); foreach (var pair in message.ToParams()) { request.Add(pair.Key, pair.Value); } var text = await SendWithRetryPolicy(request, retryPolicy).ConfigureAwait(false); return(SendEmailResponse.Parse(text).SendEmailResult); }