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
+95-17
Original file line number
Diff line number
Diff line change
@@ -124,45 +124,50 @@ You can quickly start by initializing the `DynamoDBPersistenceLayer` class and u
124
124
125
125
Similar to [idempotent decorator](#idempotent-decorator), you can use `idempotent_function` decorator for any synchronous Python function.
126
126
127
-
When using `idempotent_function`, you must tell us which keyword parameter in your function signature has the data we should use via **`data_keyword_argument`** - Such data must be JSON serializable.
127
+
When using `idempotent_function`, you must tell us which keyword parameter in your function signature has the data we should use via **`data_keyword_argument`**.
128
+
129
+
!!! info "We support JSON serializable data, [Python Dataclasses](https://docs.python.org/3.7/library/dataclasses.html){target="_blank"}, [Parser/Pydantic Models](parser.md){target="_blank"}, and our [Event Source Data Classes](./data_classes.md){target="_blank"}."
128
130
129
131
!!! warning "Make sure to call your decorated function using keyword arguments"
130
132
131
-
=== "app.py"
133
+
=== "batch_sample.py"
132
134
133
135
This example also demonstrates how you can integrate with [Batch utility](batch.md), so you can process each record in an idempotent manner.
134
136
135
-
```python hl_lines="4 13 18 25"
136
-
import uuid
137
-
138
-
from aws_lambda_powertools.utilities.batch import sqs_batch_processor
139
-
from aws_lambda_powertools.utilities.idempotency import idempotent_function, DynamoDBPersistenceLayer, IdempotencyConfig
137
+
```python hl_lines="4-5 16 21 29"
138
+
from aws_lambda_powertools.utilities.batch import (BatchProcessor, EventType,
139
+
batch_processor)
140
+
from aws_lambda_powertools.utilities.data_classes.sqs_event import SQSRecord
141
+
from aws_lambda_powertools.utilities.idempotency import (
order = Order(item=order_item, order_id="fake-id")
269
+
270
+
# `order` parameter must be called as a keyword argument to work
271
+
process_order(order=order)
272
+
```
273
+
196
274
### Choosing a payload subset for idempotency
197
275
198
276
!!! tip "Dealing with always changing payloads"
@@ -209,7 +287,7 @@ Imagine the function executes successfully, but the client never receives the re
209
287
!!! warning "Idempotency for JSON payloads"
210
288
The payload extracted by the `event_key_jmespath` is treated as a string by default, so will be sensitive to differences in whitespace even when the JSON payload itself is identical.
211
289
212
-
To alter this behaviour, we can use the [JMESPath built-in function](jmespath_functions.md#powertools_json-function) `powertools_json()` to treat the payload as a JSON object rather than a string.
290
+
To alter this behaviour, we can use the [JMESPath built-in function](jmespath_functions.md#powertools_json-function) `powertools_json()` to treat the payload as a JSON object (dict) rather than a string.
0 commit comments