- 
                Notifications
    You must be signed in to change notification settings 
- Fork 176
feat(batch): use async local storage for batch processing #4700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| 
 | 
| this.successMessages.length = 0; | ||
| this.failureMessages.length = 0; | ||
| this.errors.length = 0; | ||
| this.successMessages = []; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed this because it seemed odd to be just setting the length to 0 rather than just resetting the variable as is done elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a question. Nice one on using getters/setter to minimize changes
| record, | ||
| new SqsFifoShortCircuitError() | ||
| ); | ||
| processedRecords.push(result); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we miss having this previously?
| record, | ||
| new SqsFifoShortCircuitError() | ||
| ); | ||
| processedRecords.push(result); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same in here, was there a bug because of this?



Summary
This PR adds support for using an async context (specifically from the InvokeStore package) in the Batch utility. This allows users to process batches that are isolated specifically to the current lambda invocation, isolated from any other executions.
Changes
InvokeStoreto persist state across invocations.BatchProcessingStoreSqsFifoProcessorStoreBatchProcessingStoreclass: if we followed the pattern of replacing all in place mutation with specific methods that guard against mutating the underlying resources, this would entail far more changes to the code across the mutliple subclasses. Instead, I have chose to use getters and setters to proxy updates to the store to ensure the the amount of changes to the code are minimised.BatchProcessorandSqsFifoPartialProcessorclasses that use them.Issue number: closes #4676
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.