-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(batch): Batch processing wrapper function (#1605)
* Refactored some types, added function wrapper and base test * Added record check and tests, renamed factories * Refactored type check logic in function * Refactor test to remove error ignore
- Loading branch information
1 parent
9d8df3d
commit cf499e1
Showing
8 changed files
with
299 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
BasePartialBatchProcessor, | ||
BaseRecord, | ||
EventType, | ||
PartialItemFailureResponse, | ||
} from '.'; | ||
|
||
const processPartialResponse = async ( | ||
event: { Records: BaseRecord[] }, | ||
recordHandler: CallableFunction, | ||
processor: BasePartialBatchProcessor | ||
): Promise<PartialItemFailureResponse> => { | ||
if (!event.Records) { | ||
const eventTypes: string = Object.values(EventType).toString(); | ||
throw new Error( | ||
'Failed to convert event to record batch for processing.\nPlease ensure batch event is a valid ' + | ||
eventTypes + | ||
' event.' | ||
); | ||
} | ||
|
||
const records = event['Records']; | ||
|
||
processor.register(records, recordHandler); | ||
await processor.process(); | ||
|
||
return processor.response(); | ||
}; | ||
|
||
export { processPartialResponse }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.