示例#1
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task FunctionHandler(string input, ILambdaContext context)
        {
            IAmazonSQS              sqsClient              = new AmazonSQSClient();
            ISqsAdapter             sqsAdapter             = new SqsAdapter(sqsClient, "");
            IAmazonS3               s3Client               = new AmazonS3Client();
            IS3Adapter              s3Adapter              = new S3Adapter(s3Client);
            IEmailMessageRepository emailMessageRepository = new EmailMessageRepository(sqsAdapter, s3Adapter);

            IAmazonSimpleEmailService sesClient   = new AmazonSimpleEmailServiceClient();
            IEmailDeliveryConfig      emailConfig = new EmailDeliveryConfig()
            {
                FromAddress = ""
            };
            ISESAdapter           sesAdapter      = new SESAdapter(sesClient, emailConfig);
            IEmailMessageDelivery messageDelivery = new EmailMessageDelivery(sesAdapter);
            IEmailQueueProcessor  emailProcessor  = new EmailQueueProcessor(emailMessageRepository, messageDelivery);

            var emptyProcesses = 0;

            while (emptyProcesses <= 3 && context.RemainingTime > TimeSpan.FromSeconds(30))
            {
                var count = await emailProcessor.ProcessEmailMessages();

                if (count == 0)
                {
                    emptyProcesses++;
                }
            }
        }
示例#2
0
 public HomeController(ILogger <HomeController> logger)
 {
     _logger     = logger;
     _s3_adapter = new S3Adapter();
     _db_adapter = new DynamoDBAdapter();
 }