Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public async Task <GetSendQuotaResult> GetSendQuotaAsync(SesEmail message)
        {
            var request = new SesRequest("GetSendQuota");

            var text = await Send(request).ConfigureAwait(false);

            return(GetSendQuotaResponse.Parse(text).GetSendQuotaResult);
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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);
        }