diff --git a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/README.md b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/README.md index 5e1d4754..3b568f76 100644 --- a/libraries/src/AWS.Lambda.Powertools.BatchProcessing/README.md +++ b/libraries/src/AWS.Lambda.Powertools.BatchProcessing/README.md @@ -1,14 +1,59 @@ # AWS.Lambda.Powertools.BatchProcessing -... + +The batch processing utility handles partial failures when processing batches from Amazon SQS, Amazon Kinesis Data Streams, and Amazon DynamoDB Streams. ## Key features -... + +* Reports batch item failures to reduce number of retries for a record upon errors +* Simple interface to process each batch record +* Bring your own batch processor +* Parallel processing + +## Background + +When using SQS, Kinesis Data Streams, or DynamoDB Streams as a Lambda event source, your Lambda functions are triggered with a batch of messages. + +If your function fails to process any message from the batch, the entire batch returns to your queue or stream. This same batch is then retried until either condition happens first: a) your Lambda function returns a successful response, b) record reaches maximum retry attempts, or c) when records expire. + +This behavior changes when you enable Report Batch Item Failures feature in your Lambda function event source configuration: + +* [SQS queues](https://docs.powertools.aws.dev/lambda/dotnet/utilities/batch-processing/#sqs-standard). Only messages reported as failure will return to the queue for a retry, while successful ones will be deleted. +* [Kinesis data streams](https://docs.powertools.aws.dev/lambda/dotnet/utilities/batch-processing/#kinesis-and-dynamodb-streams) and [DynamoDB streams](https://docs.powertools.aws.dev/lambda/dotnet/utilities/batch-processing/#kinesis-and-dynamodb-streams). Single reported failure will use its sequence number as the stream checkpoint. Multiple reported failures will use the lowest sequence number as checkpoint. ## Read the docs -... + +For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/utilities/batch-processing/](https://docs.powertools.aws.dev/lambda/dotnet/utilities/batch-processing/) + +GitHub: https://github.com/aws-powertools/powertools-lambda-dotnet/ ## Sample Function -... -## Sample output -... \ No newline at end of file +View the full example here: [github.com/aws-powertools/powertools-lambda-dotnet/tree/develop/examples/BatchProcessing](https://github.com/aws-powertools/powertools-lambda-dotnet/tree/develop/examples/BatchProcessing) + +```csharp +[BatchProcessor(RecordHandler = typeof(CustomSqsRecordHandler))] +public BatchItemFailuresResponse HandlerUsingAttribute(SQSEvent _) +{ + return SqsBatchProcessor.Result.BatchItemFailuresResponse; +} + +public class CustomSqsRecordHandler : ISqsRecordHandler +{ + public async Task HandleAsync(SQSEvent.SQSMessage record, CancellationToken cancellationToken) + { + /* + Your business logic. + If an exception is thrown, the item will be marked as a partial batch item failure. + */ + + var product = JsonSerializer.Deserialize(record.Body); + + if (product.GetProperty("Id").GetInt16() == 4) + { + throw new ArgumentException("Error on 4"); + } + + return await Task.FromResult(RecordHandlerResult.None); + } +} +``` \ No newline at end of file diff --git a/libraries/src/AWS.Lambda.Powertools.Common/README.md b/libraries/src/AWS.Lambda.Powertools.Common/README.md index 55cab450..720ce7ff 100644 --- a/libraries/src/AWS.Lambda.Powertools.Common/README.md +++ b/libraries/src/AWS.Lambda.Powertools.Common/README.md @@ -1,3 +1,5 @@ # AWS.Lambda.Powertools.Common Powertools for AWS Lambda (.NET) Common library + +### As of release 1.7.0 of Powertools for AWS Lambda (.NET) this package is no longer required. For that reason It’s being deprecated and is no longer maintained. diff --git a/libraries/src/AWS.Lambda.Powertools.Idempotency/README.md b/libraries/src/AWS.Lambda.Powertools.Idempotency/README.md index 2ebf57fc..fe76b5a7 100644 --- a/libraries/src/AWS.Lambda.Powertools.Idempotency/README.md +++ b/libraries/src/AWS.Lambda.Powertools.Idempotency/README.md @@ -18,9 +18,15 @@ times with the same parameters**. This makes idempotent operations safe to retry * Prevent Lambda handler function from executing more than once on the same event payload during a time window * Ensure Lambda handler returns the same result when called with the same payload -* Select a subset of the event as the idempotency key using JMESPath expressions +* Select a subset of the event as the idempotency key using [JMESPath](https://jmespath.org/) expressions * Set a time window in which records with the same payload should be considered duplicates +* Expires in-progress executions if the Lambda function times out halfway through +## Read the docs + +For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/utilities/idempotency/](https://docs.powertools.aws.dev/lambda/dotnet/utilities/idempotency/) + +GitHub: https://github.com/aws-powertools/powertools-lambda-dotnet/ ## Installation You should install with NuGet: @@ -35,5 +41,20 @@ Or via the .NET Core command line interface: dotnet add package Amazon.Lambda.PowerTools.Idempotency ``` -## Acknowledgment -This project has been ported from the Java Idempotency PowerTool Utility +## Sample Function + +```csharp +public class Function +{ + public Function() + { + Idempotency.Configure(builder => builder.UseDynamoDb("idempotency_table")); + } + + [Idempotent] + public Task FunctionHandler(string input, ILambdaContext context) + { + return Task.FromResult(input.ToUpper()); + } +} +``` diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/README.md b/libraries/src/AWS.Lambda.Powertools.Logging/README.md index 17115f18..9e48f4bc 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/README.md +++ b/libraries/src/AWS.Lambda.Powertools.Logging/README.md @@ -11,7 +11,7 @@ The logging utility provides a [AWS Lambda](https://aws.amazon.com/lambda/) opti ## Read the docs -For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/core/logging/](docs.powertools.aws.dev/lambda/dotnet/core/logging/) +For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/core/logging/](https://docs.powertools.aws.dev/lambda/dotnet/core/logging/) GitHub: https://github.com/aws-powertools/powertools-lambda-dotnet/ diff --git a/libraries/src/AWS.Lambda.Powertools.Metrics/README.md b/libraries/src/AWS.Lambda.Powertools.Metrics/README.md index fe18abca..636ae5d2 100644 --- a/libraries/src/AWS.Lambda.Powertools.Metrics/README.md +++ b/libraries/src/AWS.Lambda.Powertools.Metrics/README.md @@ -13,7 +13,7 @@ These metrics can be visualized through [Amazon CloudWatch Console](https://aws. ## Read the docs -For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/core/metrics/](docs.powertools.aws.dev/lambda/dotnet/core/metrics/) +For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/core/metrics/](https://docs.powertools.aws.dev/lambda/dotnet/core/metrics/) GitHub: https://github.com/aws-powertools/powertools-lambda-dotnet/ diff --git a/libraries/src/AWS.Lambda.Powertools.Parameters/README.md b/libraries/src/AWS.Lambda.Powertools.Parameters/README.md index 45ab95fd..85302f35 100644 --- a/libraries/src/AWS.Lambda.Powertools.Parameters/README.md +++ b/libraries/src/AWS.Lambda.Powertools.Parameters/README.md @@ -11,7 +11,7 @@ The Parameters utility provides high-level functionality to retrieve one or mult ## Read the docs -For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/utilities/parameters/](docs.powertools.aws.dev/lambda/dotnet/utilities/parameters/) +For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/utilities/parameters/](https://docs.powertools.aws.dev/lambda/dotnet/utilities/parameters/) GitHub: diff --git a/libraries/src/AWS.Lambda.Powertools.Tracing/README.md b/libraries/src/AWS.Lambda.Powertools.Tracing/README.md index db512510..41bbc937 100644 --- a/libraries/src/AWS.Lambda.Powertools.Tracing/README.md +++ b/libraries/src/AWS.Lambda.Powertools.Tracing/README.md @@ -13,7 +13,7 @@ a provides functionality to reduce the overhead of performing common tracing tas ## Read the docs -For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/core/tracing/](docs.powertools.aws.dev/lambda/dotnet/core/tracing/) +For a full list of features go to [docs.powertools.aws.dev/lambda/dotnet/core/tracing/](https://docs.powertools.aws.dev/lambda/dotnet/core/tracing/) **GitHub:** https://github.com/aws-powertools/powertools-lambda-dotnet/