Skip to content

Conversation

@svozza
Copy link
Contributor

@svozza svozza commented Oct 29, 2025

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

  • Added storage classes to abstract the use of InvokeStore to persist state across invocations.
  • Added a storage class for the state (records, handlers, failures etc) associated with batch processing: BatchProcessingStore
  • Add a storage class for SQS FIFO processing to track group IDs: SqsFifoProcessorStore
  • The Batch Processor class are highly stateful with mutiple subclasses that mutate instance variables across the class hierarchy. As such I have taken a slightly different approach to incorporating the BatchProcessingStore class: 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.
  • Added specific concurrency tests for both stores and also the BatchProcessor and SqsFifoPartialProcessor classes 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.

@boring-cyborg boring-cyborg bot added batch This item relates to the Batch Processing Utility dependencies Changes that touch dependencies, e.g. Dependabot, etc. tests PRs that add or change tests labels Oct 29, 2025
@pull-request-size pull-request-size bot added the size/XXL PRs with 1K+ LOC, largely documentation related label Oct 29, 2025
@svozza svozza requested a review from sdangol October 29, 2025 17:31
@sonarqubecloud
Copy link

this.successMessages.length = 0;
this.failureMessages.length = 0;
this.errors.length = 0;
this.successMessages = [];
Copy link
Contributor Author

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.

@svozza svozza self-assigned this Oct 29, 2025
Copy link
Contributor

@sdangol sdangol left a 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);
Copy link
Contributor

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);
Copy link
Contributor

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?

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

Labels

batch This item relates to the Batch Processing Utility dependencies Changes that touch dependencies, e.g. Dependabot, etc. size/XXL PRs with 1K+ LOC, largely documentation related tests PRs that add or change tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Allow use of InvokeStore in Batch Processor

2 participants