Skip to content

Commit 9d489ad

Browse files
committed
fix: docstring example, param description for idempotency_function
1 parent 87cacb5 commit 9d489ad

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

aws_lambda_powertools/utilities/idempotency/idempotency.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def idempotent(
2525
**kwargs,
2626
) -> Any:
2727
"""
28-
Middleware to handle idempotency
28+
Decorator to handle idempotency
2929
3030
Parameters
3131
----------
@@ -78,33 +78,33 @@ def idempotent_function(
7878
config: Optional[IdempotencyConfig] = None,
7979
) -> Any:
8080
"""
81-
Middleware to handle idempotency of any function
81+
Decorator to handle idempotency of any function
8282
8383
Parameters
8484
----------
8585
function: Callable
8686
Function to be decorated
87-
data_keyword_argument: Dict
88-
Lambda's Event
87+
data_keyword_argument: str
88+
Keyword parameter name in function's signature that we should hash as idempotency key, e.g. "order"
8989
persistence_store: BasePersistenceLayer
9090
Instance of BasePersistenceLayer to store data
9191
config: IdempotencyConfig
9292
Configuration
9393
9494
Examples
9595
--------
96-
**Processes Lambda's event in an idempotent manner**
96+
**Processes an order in an idempotent manner**
9797
98-
>>> from aws_lambda_powertools.utilities.idempotency import (
99-
>>> idempotent, DynamoDBPersistenceLayer, IdempotencyConfig
100-
>>> )
101-
>>>
102-
>>> idem_config=IdempotencyConfig(event_key_jmespath="body")
103-
>>> persistence_layer = DynamoDBPersistenceLayer(table_name="idempotency_store")
104-
>>>
105-
>>> @idempotent(config=idem_config, persistence_store=persistence_layer)
106-
>>> def handler(event, context):
107-
>>> return {"StatusCode": 200}
98+
from aws_lambda_powertools.utilities.idempotency import (
99+
idempotent_function, DynamoDBPersistenceLayer, IdempotencyConfig
100+
)
101+
102+
idem_config=IdempotencyConfig(event_key_jmespath="order_id")
103+
persistence_layer = DynamoDBPersistenceLayer(table_name="idempotency_store")
104+
105+
@idempotent_function(data_keyword_argument="order", config=idem_config, persistence_store=persistence_layer)
106+
def process_order(customer_id: str, order: dict, **kwargs):
107+
return {"StatusCode": 200}
108108
"""
109109

110110
if function is None:

0 commit comments

Comments
 (0)