Skip to content

Commit dbbd6f5

Browse files
committed
docs(idempotency): cleanup intro and key features
1 parent 0a46164 commit dbbd6f5

File tree

1 file changed

+5
-81
lines changed

1 file changed

+5
-81
lines changed

docs/utilities/idempotency.md

Lines changed: 5 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ description: Utility
55

66
<!-- markdownlint-disable MD051 -->
77

8-
The idempotency utility provides a simple solution to convert your Lambda functions into idempotent operations which are safe to retry.
8+
The idempotency utility allows you to retry operations with the same input within a time window, producing the same output.
99

1010
## Key features
1111

12-
* Prevent Lambda handler from executing more than once on the same event payload during a time window
13-
* Ensure Lambda handler returns the same result when called with the same payload
14-
* Select a subset of the event as the idempotency key using JMESPath expressions
15-
* Set a time window in which records with the same payload should be considered duplicates
16-
* Expires in-progress executions if the Lambda function times out halfway through
17-
* Support Amazon DynamoDB and Redis as persistence layers
12+
* Produces the same result when a function is called repeatedly with the same idempotency key
13+
* Choose your idempotency key from one or more fields, or entire payload
14+
* Safeguard concurrent requests, timeouts, missing idempotency keys, and payload tampering
15+
* Support for Amazon DynamoDB, Redis, and bring your own persistence layer
1816

1917
## Terminology
2018

@@ -421,87 +419,13 @@ For security, we enforce SSL connections by default; to disable it, set `ssl=Fal
421419
--8<-- "examples/idempotency/src/getting_started_with_idempotency_redis_client.py"
422420
```
423421

424-
=== "Sample event"
425-
426-
```json
427-
--8<-- "examples/idempotency/src/getting_started_with_idempotency_payload.json"
428-
```
429-
430-
##### Redis SSL connections
431-
432-
We recommend using AWS Secrets Manager to store and rotate certificates safely, and the [Parameters feature](./parameters.md){target="_blank"} to fetch and cache optimally.
433-
434-
For advanced configurations, we also recommend using an existing Redis client for optimal compatibility like SSL certificates and timeout.
435-
436-
=== "Advanced configuration using AWS Secrets"
437-
```python hl_lines="9-11 13 15 25"
438-
--8<-- "examples/idempotency/src/using_redis_client_with_aws_secrets.py"
439-
```
440-
441-
1. JSON stored:
442-
```json
443-
{
444-
"REDIS_ENDPOINT": "127.0.0.1",
445-
"REDIS_PORT": "6379",
446-
"REDIS_PASSWORD": "redis-secret"
447-
}
448-
```
449-
450-
=== "Advanced configuration with local certificates"
451-
```python hl_lines="14 25-27"
452-
--8<-- "examples/idempotency/src/using_redis_client_with_local_certs.py"
453-
```
454-
455-
1. JSON stored:
456-
```json
457-
{
458-
"REDIS_ENDPOINT": "127.0.0.1",
459-
"REDIS_PORT": "6379",
460-
"REDIS_PASSWORD": "redis-secret"
461-
}
462-
```
463-
2. redis_user.crt file stored in the "certs" directory of your Lambda function
464-
3. redis_user_private.key file stored in the "certs" directory of your Lambda function
465-
4. redis_ca.pem file stored in the "certs" directory of your Lambda function
466-
467-
##### Redis defaults
468-
469-
You can customize attribute names when instantiating `RedisCachePersistenceLayer` with the following parameters:
470-
471422
| Parameter | Required | Default | Description |
472423
| --------------------------- | -------- | ------------------------ | --------------------------------------------------------------------------------------------- |
473424
| **in_progress_expiry_attr** | | `in_progress_expiration` | Unix timestamp of when record expires while in progress (in case of the invocation times out) |
474425
| **status_attr** | | `status` | Stores status of the Lambda execution during and after invocation |
475426
| **data_attr** | | `data` | Stores results of successfully executed Lambda handlers |
476427
| **validation_key_attr** | | `validation` | Hashed representation of the parts of the event used for validation |
477428

478-
```python title="customize_persistence_layer_redis.py" hl_lines="15-18"
479-
--8<-- "examples/idempotency/src/customize_persistence_layer_redis.py"
480-
```
481-
482-
### Common use cases
483-
484-
#### Batch integration
485-
486-
You can can easily integrate with [Batch](batch.md){target="_blank"} with the [idempotent_function decorator](#idempotent_function-decorator) to handle idempotency per message/record in a given batch.
487-
488-
???+ "Choosing an unique batch record attribute"
489-
In this example, we choose `messageId` as our idempotency key since we know it'll be unique.
490-
491-
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.
492-
493-
=== "Integration with Batch Processor"
494-
495-
```python title="integrate_idempotency_with_batch_processor.py" hl_lines="3 16 19 25 27"
496-
--8<-- "examples/idempotency/src/integrate_idempotency_with_batch_processor.py"
497-
```
498-
499-
=== "Sample event"
500-
501-
```json title="integrate_idempotency_with_batch_processor_payload.json" hl_lines="4"
502-
--8<-- "examples/idempotency/src/integrate_idempotency_with_batch_processor_payload.json"
503-
```
504-
505429
### Idempotency request flow
506430

507431
The following sequence diagrams explain how the Idempotency feature behaves under different scenarios.

0 commit comments

Comments
 (0)