Skip to content

Commit 8b6a68b

Browse files
docs(idempotency): Correct examples and line highlights (#312)
1 parent 696f93e commit 8b6a68b

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ A suite of Python utilities for AWS Lambda functions to ease adopting best pract
1616
* **[Metrics](https://awslabs.github.io/aws-lambda-powertools-python/core/metrics/)** - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF)
1717
* **[Bring your own middleware](https://awslabs.github.io/aws-lambda-powertools-python/utilities/middleware_factory/)** - Decorator factory to create your own middleware to run logic before, and after each Lambda invocation
1818
* **[Parameters utility](https://awslabs.github.io/aws-lambda-powertools-python/utilities/parameters/)** - Retrieve and cache parameter values from Parameter Store, Secrets Manager, or DynamoDB
19-
* **[Batch processing](https://awslabs.github.io/aws-lambda-powertools-python/utilities/batch)** - Handle partial failures for AWS SQS batch processing
20-
* **[Typing](https://awslabs.github.io/aws-lambda-powertools-python/utilities/typing)** - Static typing classes to speedup development in your IDE
21-
* **[Validation](https://awslabs.github.io/aws-lambda-powertools-python/utilities/validation)** - JSON Schema validator for inbound events and responses
22-
* **[Event source data classes](https://awslabs.github.io/aws-lambda-powertools-python/utilities/data_classes)** - Data classes describing the schema of common Lambda event triggers
23-
* **[Parser](https://awslabs.github.io/aws-lambda-powertools-python/utilities/parser)** - Data parsing and deep validation using Pydantic
19+
* **[Batch processing](https://awslabs.github.io/aws-lambda-powertools-python/utilities/batch/)** - Handle partial failures for AWS SQS batch processing
20+
* **[Typing](https://awslabs.github.io/aws-lambda-powertools-python/utilities/typing/)** - Static typing classes to speedup development in your IDE
21+
* **[Validation](https://awslabs.github.io/aws-lambda-powertools-python/utilities/validation/)** - JSON Schema validator for inbound events and responses
22+
* **[Event source data classes](https://awslabs.github.io/aws-lambda-powertools-python/utilities/data_classes/)** - Data classes describing the schema of common Lambda event triggers
23+
* **[Parser](https://awslabs.github.io/aws-lambda-powertools-python/utilities/parser/)** - Data parsing and deep validation using Pydantic
24+
* **[Idempotency](https://awslabs.github.io/aws-lambda-powertools-python/utilities/idempotency/)** - Convert your Lambda functions into idempotent operations which are safe to retry
2425

2526
### Installation
2627

docs/utilities/idempotency.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ You can quickly start by initializing the `DynamoDBPersistenceLayer` class and u
8484

8585
=== "app.py"
8686

87-
```python hl_lines="1 5 7 14"
87+
```python hl_lines="1-3 5 7 14"
8888
from aws_lambda_powertools.utilities.idempotency import (
8989
DynamoDBPersistenceLayer, idempotent
9090
)
@@ -186,7 +186,7 @@ Imagine the function executes successfully, but the client never receives the re
186186
"time":"10/Feb/2021:13:40:43 +0000",
187187
"timeEpoch":1612964443723
188188
},
189-
"body":"{\"username\":\"xyz\",\"product_id\":\"123456789\"}",
189+
"body":"{\"user\":\"xyz\",\"product_id\":\"123456789\"}",
190190
"isBase64Encoded":false
191191
}
192192
```
@@ -223,7 +223,7 @@ This persistence layer is built-in, and you can either use an existing DynamoDB
223223

224224
=== "app.py"
225225

226-
```python hl_lines="3-7"
226+
```python hl_lines="5-9"
227227
from aws_lambda_powertools.utilities.idempotency import DynamoDBPersistenceLayer
228228

229229
persistence_layer = DynamoDBPersistenceLayer(
@@ -232,7 +232,7 @@ This persistence layer is built-in, and you can either use an existing DynamoDB
232232
expiry_attr="expires_at",
233233
status_attr="current_status",
234234
data_attr="result_data",
235-
validation_key_attr="validation_key"
235+
validation_key_attr="validation_key",
236236
)
237237
```
238238

@@ -246,6 +246,7 @@ Parameter | Required | Default | Description
246246
**status_attr** | | `status` | Stores status of the lambda execution during and after invocation
247247
**data_attr** | | `data` | Stores results of successfully executed Lambda handlers
248248
**validation_key_attr** | | `validation` | Hashed representation of the parts of the event used for validation
249+
249250
## Advanced
250251

251252
### Customizing the default behavior
@@ -259,7 +260,7 @@ Parameter | Default | Description
259260
**raise_on_no_idempotency_key** | `False` | Raise exception if no idempotency key was found in the request
260261
**expires_after_seconds** | 3600 | The number of seconds to wait before a record is expired
261262
**use_local_cache** | `False` | Whether to locally cache idempotency results
262-
**local_cache_max_items** | 1024 | Max number of items to store in local cache
263+
**local_cache_max_items** | 256 | Max number of items to store in local cache
263264
**hash_function** | `md5` | Function to use for calculating hashes, as provided by [hashlib](https://docs.python.org/3/library/hashlib.html) in the standard library.
264265

265266
### Handling concurrent executions with the same payload
@@ -281,16 +282,15 @@ You can enable in-memory caching with the **`use_local_cache`** parameter:
281282

282283
=== "app.py"
283284

284-
```python hl_lines="6 8 11"
285+
```python hl_lines="8 11"
285286
from aws_lambda_powertools.utilities.idempotency import (
286287
IdempotencyConfig, DynamoDBPersistenceLayer, idempotent
287288
)
288289

289290
persistence_layer = DynamoDBPersistenceLayer(table_name="IdempotencyTable")
290291
config = IdempotencyConfig(
291292
event_key_jmespath="body",
292-
expires_after_seconds=5*60, # 5 minutes
293-
use_local_cache=True
293+
use_local_cache=True,
294294
)
295295

296296
@idempotent(config=config, persistence_store=persistence_layer)
@@ -310,7 +310,7 @@ You can change this window with the **`expires_after_seconds`** parameter:
310310

311311
=== "app.py"
312312

313-
```python hl_lines="6 8 11"
313+
```python hl_lines="8 11"
314314
from aws_lambda_powertools.utilities.idempotency import (
315315
IdempotencyConfig, DynamoDBPersistenceLayer, idempotent
316316
)

examples/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)