Exemple #1
0
        public async Task Process(TEventType ev, ILambdaContext context)
        {
            try
            {
                await PreparePubSubMessage(ev);

                IEnumerable <TMessageType> rawData;
                if (_deprecatedExtractor != default)
                {
                    rawData = await _deprecatedExtractor.ExtractEventBody <TEventType, TMessageType>(ev);
                }
                else
                {
                    rawData = await _messageExtractor.ExtractEventBody(ev);
                }

                await HandleEvent(rawData, context);
                await HandleRawEvent(ev, context);
            }
            catch (Exception exception)
            {
                LogError(ev, exception, context);

                var result = await HandleError(ev, context, exception);

                if (result == HandleErrorResult.Throw)
                {
                    throw;
                }
            }
        }
        public async Task <SQSResponse> Process(SQSEvent ev, ILambdaContext context)
        {
            try
            {
                await PreparePubSubMessage(ev);

                var rawData = await _messageExtractor.ExtractEventBody(ev);

                var response = await HandleEvent(rawData, context);

                var responseFromRaw = await HandleRawEvent(ev, context);

                var failures = new List <BatchItemFailure>();
                failures.AddRange(response.BatchItemFailures);
                failures.AddRange(responseFromRaw.BatchItemFailures);

                return(new SQSResponse
                {
                    BatchItemFailures = failures
                });
            }
            catch (Exception exception)
            {
                LogError(ev, exception, context);

                var result = await HandleError(ev, context, exception);

                if (result == HandleErrorResult.Throw)
                {
                    throw;
                }

                return(new SQSResponse
                {
                    BatchItemFailures = ev.Records.Select(x => new BatchItemFailure {
                        ItemIdentifier = x.MessageId
                    })
                                        .ToList()
                });
            }
        }
Exemple #3
0
        public async Task Process(SNSEvent ev, ILambdaContext context)
        {
            try
            {
                await PreparePubSubMessage(ev);

                var rawData = await _messageExtractor.ExtractEventBody(ev);

                await HandleEvent(rawData, context);
                await HandleRawEvent(ev, context);
            }
            catch (Exception exception)
            {
                LogError(ev, exception, context);

                var result = await HandleError(ev, context, exception);

                if (result == HandleErrorResult.Throw)
                {
                    throw;
                }
            }
        }