Abstract
List of errors that occurred during processing
List of records that failed processing
Record handler provided by customers to process records
Optional
optionsOptions to be used during processing (optional)
List of records to be processed
List of records that were processed successfully
Abstract
cleanMethod to handle a record that failed processing
This method should be called when a record fails processing so that the processor can keep track of the error and the record that failed.
Record that failed processing
Error that was thrown
Abstract
prepareProcess all records with an asynchronous handler
Once called, the processor will create an array of promises to process each record and wait for all of them to settle before returning the results.
Before and after processing, the processor will call the prepare and clean methods respectively.
Abstract
processProcess a record with an asynchronous handler
An implementation of this method is required for asynchronous processors.
When implementing this method, you should at least call the successHandler method when a record succeeds processing and the failureHandler method when a record fails processing.
This is to ensure that the processor keeps track of the results and the records that succeeded and failed processing.
Record to be processed
Abstract
processProcess a record with a synchronous handler
An implementation of this method is required for synchronous processors.
When implementing this method, you should at least call the successHandler method when a record succeeds processing and the failureHandler method when a record fails processing.
This is to ensure that the processor keeps track of the results and the records that succeeded and failed processing.
Record to be processed
Orchestrate the processing of a batch of records synchronously and sequentially.
The method is responsible for calling the prepare method before processing the records and the clean method after processing the records.
In the middle, the method will iterate over the records and call the processRecordSync method for each record.
List of processed records
Set up the processor with the records and the handler
This method should be called before processing the records to bind the records and the handler for a specific invocation to the processor.
We use a separate method to do this rather than the constructor to allow for reusing the processor instance across multiple invocations by instantiating the processor outside of the Lambda function handler.
Array of records to be processed
CallableFunction to process each record from the batch
Optional
options: BatchProcessingOptionsOptions to be used during processing (optional)
Method to handle a record that succeeded processing
This method should be called when a record succeeds processing so that the processor can keep track of the result and the record that succeeded.
Record that succeeded processing
Result from record handler
Abstract class for batch processors.
This class provides a common interface for processing records in a batch.
Batch processors implementing this class should provide implementations for a number of abstract methods that are specific to the type of processor or the type of records being processed.
The class comes with a few helper methods and hooks that can be used to prepare the processor before processing records, clean up after processing records, and handle records that succeed or fail processing.