@@ -187,7 +187,7 @@ You can use `data_keyword_argument` to tell us the argument to extract an idempo
187
187
188
188
=== "Using Dataclasses"
189
189
190
- ```python title="working_with_idempotent_function_dataclass.py" hl_lines="3-7 11 26 39 "
190
+ ```python title="working_with_idempotent_function_dataclass.py" hl_lines="4-8 12 28 41 "
191
191
--8<-- "examples/idempotency/src/working_with_idempotent_function_dataclass.py"
192
192
```
193
193
@@ -197,7 +197,7 @@ You can use `data_keyword_argument` to tell us the argument to extract an idempo
197
197
198
198
=== "Using Pydantic"
199
199
200
- ```python title="working_with_idempotent_function_pydantic.py" hl_lines="1-5 10 23 34 "
200
+ ```python title="working_with_idempotent_function_pydantic.py" hl_lines="3-7 12 26 37 "
201
201
--8<-- "examples/idempotency/src/working_with_idempotent_function_pydantic.py"
202
202
```
203
203
@@ -215,7 +215,7 @@ The output serializer supports any JSON serializable data, **Python Dataclasses*
215
215
216
216
=== "Inferring via the return type"
217
217
218
- ```python hl_lines="6 24 25 32 36 45 "
218
+ ```python hl_lines="8 27 35 38 48 "
219
219
--8<-- "examples/idempotency/src/working_with_pydantic_deduced_output_serializer.py"
220
220
```
221
221
@@ -225,7 +225,7 @@ The output serializer supports any JSON serializable data, **Python Dataclasses*
225
225
226
226
Alternatively, you can provide an explicit model as an input to `PydanticSerializer`.
227
227
228
- ```python hl_lines="6 24 25 32 35 44 "
228
+ ```python hl_lines="8 27 35 35 47 "
229
229
--8<-- "examples/idempotency/src/working_with_pydantic_explicitly_output_serializer.py"
230
230
```
231
231
@@ -235,7 +235,7 @@ The output serializer supports any JSON serializable data, **Python Dataclasses*
235
235
236
236
=== "Inferring via the return type"
237
237
238
- ```python hl_lines="8 27-29 36 40 49 "
238
+ ```python hl_lines="9 30 38 41 51 "
239
239
--8<-- "examples/idempotency/src/working_with_dataclass_deduced_output_serializer.py"
240
240
```
241
241
@@ -245,7 +245,7 @@ The output serializer supports any JSON serializable data, **Python Dataclasses*
245
245
246
246
Alternatively, you can provide an explicit model as an input to `DataclassSerializer`.
247
247
248
- ```python hl_lines="8 27-29 36 39 48 "
248
+ ```python hl_lines="8 30 38 40 50 "
249
249
--8<-- "examples/idempotency/src/working_with_dataclass_explicitly_output_serializer.py"
250
250
```
251
251
@@ -256,7 +256,7 @@ The output serializer supports any JSON serializable data, **Python Dataclasses*
256
256
* **to_dict**. Function to convert any type to a JSON serializable dictionary before it saves into the persistent storage.
257
257
* **from_dict**. Function to convert from a dictionary retrieved from persistent storage and serialize in its original form.
258
258
259
- ```python hl_lines="8 32 36 40 50 53 "
259
+ ```python hl_lines="9 34 38 42 52 54 64 "
260
260
--8<-- "examples/idempotency/src/working_with_idempotent_function_custom_output_serializer.py"
261
261
```
262
262
@@ -274,7 +274,7 @@ By default, caching is disabled since we don't know how big your response could
274
274
275
275
=== "Enabling cache"
276
276
277
- ```python hl_lines="12 "
277
+ ```python hl_lines="15 "
278
278
--8<-- "examples/idempotency/src/working_with_local_cache.py"
279
279
```
280
280
@@ -309,7 +309,7 @@ We want to use `user_id` and `product_id` fields as our idempotency key. **If we
309
309
310
310
=== "Payment function"
311
311
312
- ```python hl_lines="5-9 16 30 "
312
+ ```python hl_lines="6-10 18 31 "
313
313
--8<-- "examples/idempotency/src/working_with_payload_subset.py"
314
314
```
315
315
@@ -327,7 +327,7 @@ By default, we protect against [concurrent executions](#handling-concurrent-exec
327
327
328
328
To prevent extended failures, use ** ` register_lambda_context ` ** function from your idempotency config to calculate and include the remaining invocation time in your idempotency record.
329
329
330
- ``` python title="working_with_lambda_timeout.py" hl_lines="11 20 "
330
+ ``` python title="working_with_lambda_timeout.py" hl_lines="14 23 "
331
331
-- 8 < -- " examples/idempotency/src/working_with_lambda_timeout.py"
332
332
```
333
333
@@ -355,7 +355,7 @@ If an exception is handled or raised **outside** your decorated function, then i
355
355
356
356
This persistence layer is built-in, allowing you to use an existing DynamoDB table or create a new one dedicated to idempotency state (recommended).
357
357
358
- ``` python title="customize_persistence_layer.py" hl_lines="7-15 "
358
+ ``` python title="customize_persistence_layer.py" hl_lines="10-18 "
359
359
-- 8 < -- " examples/idempotency/src/customize_persistence_layer.py"
360
360
```
361
361
@@ -384,12 +384,12 @@ For simple setups, initialize `RedisCachePersistenceLayer` with your cluster end
384
384
For security, we enforce SSL connections by default; to disable it, set ` ssl=False ` .
385
385
386
386
=== "Redis quick start"
387
- ```python title="getting_started_with_idempotency_redis_config.py" hl_lines="7-9 12 26 "
387
+ ```python title="getting_started_with_idempotency_redis_config.py" hl_lines="8-10 14 27 "
388
388
--8<-- "examples/idempotency/src/getting_started_with_idempotency_redis_config.py"
389
389
```
390
390
391
391
=== "Using an existing Redis client"
392
- ```python title="getting_started_with_idempotency_redis_client.py" hl_lines="4 9 -11 14 22 36 "
392
+ ```python title="getting_started_with_idempotency_redis_client.py" hl_lines="5 10 -11 16 24 38 "
393
393
--8<-- "examples/idempotency/src/getting_started_with_idempotency_redis_client.py"
394
394
```
395
395
@@ -447,7 +447,7 @@ You can customize the attribute names during initialization:
447
447
| ** data_attr** | | ` data ` | Stores results of successfully executed Lambda handlers |
448
448
| ** validation_key_attr** | | ` validation ` | Hashed representation of the parts of the event used for validation |
449
449
450
- ``` python title="customize_persistence_layer_redis.py" hl_lines="9-16 "
450
+ ``` python title="customize_persistence_layer_redis.py" hl_lines="15-18 "
451
451
-- 8 < -- " examples/idempotency/src/customize_persistence_layer_redis.py"
452
452
```
453
453
@@ -784,7 +784,7 @@ You can change this window with the **`expires_after_seconds`** parameter:
784
784
785
785
=== "Adjusting idempotency record expiration"
786
786
787
- ```python hl_lines="11 "
787
+ ```python hl_lines="14 "
788
788
--8<-- "examples/idempotency/src/working_with_record_expiration.py"
789
789
```
790
790
@@ -818,7 +818,7 @@ With **`payload_validation_jmespath`**, you can provide an additional JMESPath e
818
818
819
819
=== "Payload validation"
820
820
821
- ```python hl_lines="12 20 28 "
821
+ ```python hl_lines="16 25 32 "
822
822
--8<-- "examples/idempotency/src/working_with_validation_payload.py"
823
823
```
824
824
@@ -854,7 +854,7 @@ This means that we will raise **`IdempotencyKeyError`** if the evaluation of **`
854
854
855
855
=== "Idempotency key required"
856
856
857
- ```python hl_lines="11 "
857
+ ```python hl_lines="14 "
858
858
--8<-- "examples/idempotency/src/working_with_idempotency_key_required.py"
859
859
```
860
860
@@ -876,13 +876,13 @@ The **`boto_config`** and **`boto3_session`** parameters enable you to pass in a
876
876
877
877
=== "Custom session"
878
878
879
- ```python hl_lines="1 11 13 "
879
+ ```python hl_lines="3 13 16 "
880
880
--8<-- "examples/idempotency/src/working_with_custom_session.py"
881
881
```
882
882
883
883
=== "Custom config"
884
884
885
- ```python hl_lines="1 11 13 "
885
+ ```python hl_lines="3 13 16 "
886
886
--8<-- "examples/idempotency/src/working_with_custom_config.py"
887
887
```
888
888
@@ -902,7 +902,7 @@ You can optionally set a static value for the partition key using the `static_pk
902
902
903
903
=== "Reusing a DynamoDB table that uses a composite primary key"
904
904
905
- ```python hl_lines="7 "
905
+ ```python hl_lines="10 "
906
906
--8<-- "examples/idempotency/src/working_with_composite_key.py"
907
907
```
908
908
@@ -931,11 +931,9 @@ You can create your own persistent store from scratch by inheriting the `BasePer
931
931
* ** ` _update_record() ` ** – Updates an item in the persistence store.
932
932
* ** ` _delete_record() ` ** – Removes an item from the persistence store.
933
933
934
- === "Bring your own persistent store"
935
-
936
- ```python hl_lines="8 18 65 74 96 124"
937
- --8<-- "examples/idempotency/src/bring_your_own_persistent_store.py"
938
- ```
934
+ ``` python title="bring_your_own_persistent_store.py" hl_lines="8 18 65 74 96 124"
935
+ -- 8 < -- " examples/idempotency/src/bring_your_own_persistent_store.py"
936
+ ```
939
937
940
938
???+ danger
941
939
Pay attention to the documentation for each - you may need to perform additional checks inside these methods to ensure the idempotency guarantees remain intact.
@@ -948,7 +946,7 @@ You can set up a `response_hook` in the `IdempotentConfig` class to manipulate t
948
946
949
947
=== "Using an Idempotent Response Hook"
950
948
951
- ```python hl_lines="19 21 27 34 "
949
+ ```python hl_lines="20 22 28 36 "
952
950
--8<-- "examples/idempotency/src/working_with_response_hook.py"
953
951
```
954
952
@@ -978,7 +976,7 @@ When using response hooks to manipulate returned data from idempotent operations
978
976
979
977
See [ Batch integration] ( #batch-integration ) above.
980
978
981
- ### Validation utility
979
+ ### JSON Schema Validation
982
980
983
981
The idempotency utility can be used with the ` validator ` decorator. Ensure that idempotency is the innermost decorator.
984
982
@@ -990,7 +988,7 @@ The idempotency utility can be used with the `validator` decorator. Ensure that
990
988
991
989
=== "Using Idempotency with JSONSchema Validation utility"
992
990
993
- ```python hl_lines="13 "
991
+ ```python hl_lines="16 "
994
992
--8<-- "examples/idempotency/src/integrate_idempotency_with_validator.py"
995
993
```
996
994
0 commit comments