Closed
Description
Use case
When using a Kafka event source either from self-managed Apache Kafka or Amazon MSK there should be a relevant data class for easy iteration/decoding.
Such functionality is implemented already in aws-lambda-go and in aws-lambda-java-libs.
Solution/User Experience
Similar to other streaming data sources a records
property should be iterable returning a KafkaEventRecord
that transparently decodes the values from JSON:
from aws_lambda_powertools.utilities.data_classes import event_source, KafkaEvent
@event_source(data_class=KafkaEvent)
def handler(event: KafkaEvent, context: LambdaContext):
for record in event.records:
print(record.decoded_key, record.json_value)
Alternative solutions
No response
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Java, TypeScript