-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Enhancement
Copy link
Labels
area/batchBatch utilityBatch utilityfeature-requestNew or enhancements to existing featuresNew or enhancements to existing features
Description
Use case
Currently, batch processing utility requires developers to manually deserialize event record data within their record handlers. This leads to repetitive boilerplate code and potential inconsistencies across different handlers. Developers need to:
- Extract raw data from different event types (SQS body, Kinesis data, DynamoDB records)
- Manually deserialize JSON strings to strongly-typed objects
public class OrderHandler : ISqsRecordHandler
{
public async Task<RecordHandlerResult> HandleAsync(SQSEvent.SQSMessage record, CancellationToken cancellationToken)
{
// Manual deserialization in every handler
var order = JsonSerializer.Deserialize<Order>(record.Body);
await ProcessOrder(order);
return RecordHandlerResult.Successful;
}
}
Solution/User Experience
Introduce strongly-typed batch processing that automatically handles deserialization:
New Interface-based Approach:
public class OrderHandler : ITypedRecordHandler<Order>
{
public async Task<RecordHandlerResult> HandleAsync(Order order, CancellationToken cancellationToken)
{
// Direct access to strongly-typed object - no manual deserialization!
await ProcessOrder(order);
return RecordHandlerResult.Successful;
}
}
Key Features
- Automatic deserialization to strongly-typed objects
- Support for SQS, Kinesis, and DynamoDB events
- AOT compatibility with JsonSerializerContext
- Configurable error handling for deserialization failures
- Full backward compatibility
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (.NET) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and TypeScript
lachriz-aws
Metadata
Metadata
Assignees
Labels
area/batchBatch utilityBatch utilityfeature-requestNew or enhancements to existing featuresNew or enhancements to existing features
Type
Projects
Status
👀 In review