Skip to content

Feature request: Reduce Batch boilerplate with a facade #2083

Closed
@heitorlessa

Description

@heitorlessa

Use case

Customers have to decorate their Lambda handler with batch_processor decorator to repeatedly call a record handler for each record it walks through.

Historically, this was kept for backwards compatibility reasons as we moved from the original Batch that used AWS SDK to delete successful messages to the native Lambda integration launched two years later.

The new integration required a strict response to make it work, so we introduced a new property .response in the processor, so the Lambda handler could return it in the right format.

Now that we introduced async along with some refactoring and the new typing extensions, we have access to better tools and we can make it easier to customers onboard to the Batch feature by removing this unnecessary boilerplate in a backwards compatible way.

image

Solution/User Experience

We can introduce a new function, call it process_partial_response for the sake of argument, that is responsible to:

  • Extract Records[*] from the event, whether that is a dict or a Parser's SQS Model
  • Call the processor .process sync using the given record handler
  • Extract the final response from the processor and simply return it to the caller

Benefits. Besides reducing boilerplate and accelerate on-boarding, it'll reduce the call stack in Python improving performance a tiny wee bit.

image

Alternative solutions

No response

Acknowledgment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions