Closed
Description
Use case
This persistence layer is built-in, and you can either use an existing DynamoDB table or create a new one dedicated for idempotency state (recommended).
In scope
- Ability to configure the persistence layer via constructor:
Parameter | Required | Default | Description |
---|---|---|---|
tableName | ✔️ | Table name to store state | |
keyAttr | id |
Partition key of the table. Hashed representation of the payload (unless sort_key_attr is specified) | |
expiryAttr | expiration |
Unix timestamp of when record expires | |
inProgressExpiryAttr | in_progress_expiration |
Unix timestamp of when record expires while in progress (in case of the invocation times out) | |
statusAttr | status |
Stores status of the lambda execution during and after invocation | |
dataAttr | data |
Stores results of successfully executed Lambda handlers | |
validationKeyAttr | validation |
Hashed representation of the parts of the event used for validation | |
sortKeyAttr | Sort key of the table (if table is configured with a sort key). | ||
staticPkValue | idempotency#{LAMBDA_FUNCTION_NAME} |
Static value to use as the partition key. Only used when sort_key_attr is set. |
- Ability to pass
clientConfig
orawsSdkV3Client
to respectively configure the AWS SDK client of the persistence layer or pass a custom SDK client altogether - Handling errors and exceptions IdempotencyItemNotFound, IdempotencyInvalidStatus, IdempotencyInconsistentState
- Handling scenario of execution happening in sequence and in parallel
- Unit tests
Out of scope
- End to End tests (Maintenance: write end-to-end tests for the utility #1098)
- Documentation (Docs: write main docs for the utility #1101, Docs: mark the utility as public in the
package.json
file #1102) - Examples (Docs: refresh examples #1103)
- Github actions and CI/CD pipelines (Maintenance: integrate into CI/CD package measurement #1099)
- API docs (Docs: create API docs #1104)
Expected behaviour
- Payload ABCD is passed to the idempotent target
- Business logic calls the persistence layer to get or set a new record based on payload
- The persistence layer record based on the unique payload is marked as locked
- The idempotent target processes the payload
- The persistence layer record is updated with the result of this processing
- Payload ABCD is passed to the idempotent target (again)
- The idempotent target calls the persistence layer to get or set a new record based on payload
- If the existing record has expired, the existing result & status of the previous idempotency record will be overwritten with the new in-progress record
- If the existing record has not expired, the existing record's value will be used and returned
Solution/User Experience
Alternative solutions
No response
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Python, Java