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/utilities/idempotency.md
+80-69
Original file line number
Diff line number
Diff line change
@@ -132,75 +132,6 @@ When using `idempotent_function`, you must tell us which keyword parameter in yo
132
132
133
133
DynamoDB Persistency layer uses a Resource client [which is not thread-safe](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/resources.html?highlight=multithreading#multithreading-or-multiprocessing-with-resources){target="_blank"}.
134
134
135
-
=== "batch_sample.py"
136
-
137
-
This example also demonstrates how you can integrate with [Batch utility](batch.md), so you can process each record in an idempotent manner.
138
-
139
-
```python hl_lines="4-5 16 21 30"
140
-
from aws_lambda_powertools.utilities.batch import (BatchProcessor, EventType,
141
-
batch_processor)
142
-
from aws_lambda_powertools.utilities.data_classes.sqs_event import SQSRecord
143
-
from aws_lambda_powertools.utilities.idempotency import (
@@ -276,6 +207,82 @@ When using `idempotent_function`, you must tell us which keyword parameter in yo
276
207
process_order(order=order)
277
208
```
278
209
210
+
#### Batch integration
211
+
212
+
You can can easily integrate with [Batch utility](batch.md) via context manager. This ensures that you process each record in an idempotent manner, and guard against a [Lambda timeout](#lambda-timeouts) idempotent situation.
213
+
214
+
???+ "Choosing an unique batch record attribute"
215
+
In this example, we choose `messageId` as our idempotency token since we know it'll be unique.
216
+
217
+
Depending on your use case, it might be more accurate [to choose another field](#choosing-a-payload-subset-for-idempotency) your producer intentionally set to define uniqueness.
218
+
219
+
=== "batch_sample.py"
220
+
221
+
```python hl_lines="3-4 10 15 21 25-26 29 31"
222
+
from aws_lambda_powertools.utilities.batch import BatchProcessor, EventType
223
+
from aws_lambda_powertools.utilities.data_classes.sqs_event import SQSRecord
224
+
from aws_lambda_powertools.utilities.idempotency import (
0 commit comments