You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/utilities/batch.mdx
+37-30
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,7 @@ import Note from "../../src/components/Note"
7
7
8
8
One very attractive feature of Lambda functions is the ability to integrate them with a plethora of internal and external [event sources][1]. Some of these event providers allows a feature called "Batch processing" in which [predefined number][2] of events is sent to lambda function at once.
9
9
10
-
The proposed batch utility aims to provide an abstraction to process batch events, providing base classes (`BaseProcessor`, `BasePartialProcessor`) allowing you to create your **own** batch processor.
11
-
It also provides a useful implementation to handle partial batch failures from the SQS provider.
10
+
The proposed batch utility aims to provide an abstraction to handle a partial failure during a batch execution from a SQS event source, providing a base class (`BasePartialProcessor`) allowing you to create your **own** batch processor.
You can create your own batch processor by inheriting the `BaseProcessor` class, and implementing `_prepare()`, `_clean` and `_process_record()`.
69
-
It's also possible to inherit the `BasePartialProcessor` which contains additional logic to handle a partial failure and keep track of record status.
67
+
You can create your own partial batch processor by inheriting the `BasePartialProcessor` class, and implementing `_prepare()`, `_clean()` and `_process_record()`.
68
+
69
+
All processing logic is handled by `_process_record()` whilst `_prepare()` and `clean()` take care of doing a setup/teardown of the processor, being called at start/end of processor's execution, respectively.
70
70
71
71
**Example:**
72
72
73
73
```python:title=custom_processor.py
74
-
fromuuidimportuuid4
74
+
fromrandomimportrandint
75
75
76
-
from aws_lambda_powertools.utilities.batch importBaseProcessor, batch_processor
76
+
from aws_lambda_powertools.utilities.batch importBasePartialProcessor, batch_processor
0 commit comments