Skip to content

Conversation

hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Oct 8, 2025

Please provide the issue number

Issue number: closes #1033

Summary

Changes

Full support for TypedRecordHandler and TypedRecordHandlerWithContext

public class Product
    {
        public int Id { get; set; }
        public string? Name { get; set; }
        public decimal Price { get; set; }
    }

    public class TypedSqsRecordHandler : ITypedRecordHandler<Product> // (1)!
    {
    	public async Task<RecordHandlerResult> HandleAsync(Product product, CancellationToken cancellationToken)
    	{
    		 /*
    		 * Your business logic with automatic deserialization.
    		 * If an exception is thrown, the item will be marked as a partial batch item failure.
             */

             Logger.LogInformation($"Processing product {product.Id} - {product.Name} (${product.Price})");

             if (product.Id == 4) // (2)!
             {
                 throw new ArgumentException("Error on id 4");
             }

             return await Task.FromResult(RecordHandlerResult.None); // (3)!
         }

	}

    [BatchProcessor(TypedRecordHandler = typeof(TypedSqsRecordHandler))]
    public BatchItemFailuresResponse HandlerUsingTypedAttribute(SQSEvent _)
    {
    	return TypedSqsBatchProcessor.Result.BatchItemFailuresResponse; // (4)!
    }

User experience

Please share what the user experience looks like before and after this change

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

- Updated BatchProcessorAttribute to allow configuration of typed handlers for DynamoDB, Kinesis, and SQS events.
- Introduced CreateTypedBatchProcessingAspectHandler method to handle typed batch processing.
- Added validation for typed handler configurations.
- Implemented singleton instances for TypedDynamoDbStreamBatchProcessor, TypedKinesisEventBatchProcessor, and TypedSqsBatchProcessor.
- Refactored constructors to accept Powertools configurations and default services for typed processors.
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation tests labels Oct 8, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 8, 2025
@hjgraca hjgraca changed the title Feat/batch typed decorator feat: batch typed decorator Oct 8, 2025
@github-actions github-actions bot added the feature New features or minor changes label Oct 8, 2025
@hjgraca
Copy link
Contributor Author

hjgraca commented Oct 8, 2025

the documentation file was wrongly formated fixed, so looks like the whole file changed but in reality just one line

Copy link

codecov bot commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 77.23214% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.25%. Comparing base (b060344) to head (c8a3282).

Files with missing lines Patch % Lines
...ertools.BatchProcessing/BatchProcessorAttribute.cs 77.67% 21 Missing and 4 partials ⚠️
...sing/Internal/TypedBatchProcessingAspectHandler.cs 85.50% 6 Missing and 4 partials ⚠️
...cessing/Kinesis/TypedKinesisEventBatchProcessor.cs 42.85% 8 Missing ⚠️
...sing/DynamoDb/TypedDynamoDbStreamBatchProcessor.cs 64.28% 5 Missing ⚠️
...ools.BatchProcessing/Sqs/TypedSqsBatchProcessor.cs 78.57% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1034      +/-   ##
===========================================
+ Coverage    78.12%   78.25%   +0.13%     
===========================================
  Files          298      299       +1     
  Lines        12003    12222     +219     
  Branches      1441     1471      +30     
===========================================
+ Hits          9377     9564     +187     
- Misses        2163     2189      +26     
- Partials       463      469       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

sonarqubecloud bot commented Oct 8, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feature New features or minor changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Batch processing Typed decorator support

1 participant