Skip to content

Feature request: DynamoDB persistence layer #1294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
saragerion opened this issue Feb 17, 2023 · 1 comment · Fixed by #1376
Closed
1 of 2 tasks

Feature request: DynamoDB persistence layer #1294

saragerion opened this issue Feb 17, 2023 · 1 comment · Fixed by #1376
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility idempotency This item relates to the Idempotency Utility

Comments

@saragerion
Copy link
Contributor

saragerion commented Feb 17, 2023

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 or awsSdkV3Client 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

Expected behaviour

  1. Payload ABCD is passed to the idempotent target
  2. Business logic calls the persistence layer to get or set a new record based on payload
  3. The persistence layer record based on the unique payload is marked as locked
  4. The idempotent target processes the payload
  5. The persistence layer record is updated with the result of this processing
  6. Payload ABCD is passed to the idempotent target (again)
  7. 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

See: https://awslabs.github.io/aws-lambda-powertools-python/2.7.1/utilities/idempotency/#persistence-layers

Alternative solutions

No response

Acknowledgment

@saragerion saragerion added triage This item has not been triaged by a maintainer, please wait feature-request This item refers to a feature request for an existing or new utility labels Feb 17, 2023
@saragerion saragerion added this to the Idempotency - Beta release milestone Feb 17, 2023
@saragerion saragerion changed the title Feature request (idempotenty): DynamoDB persistence layer Feature request (idempotency): DynamoDB persistence layer Feb 17, 2023
@dreamorosi dreamorosi added idempotency This item relates to the Idempotency Utility confirmed The scope is clear, ready for implementation and removed triage This item has not been triaged by a maintainer, please wait labels Feb 17, 2023
@dreamorosi dreamorosi changed the title Feature request (idempotency): DynamoDB persistence layer Feature request: DynamoDB persistence layer Feb 17, 2023
@dreamorosi dreamorosi added discussing The issue needs to be discussed, elaborated, or refined and removed confirmed The scope is clear, ready for implementation labels Feb 17, 2023
@dreamorosi dreamorosi moved this from Backlog to Working on it in AWS Lambda Powertools for TypeScript Mar 18, 2023
@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation and removed discussing The issue needs to be discussed, elaborated, or refined labels Mar 18, 2023
@dreamorosi dreamorosi self-assigned this Mar 18, 2023
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in AWS Lambda Powertools for TypeScript Mar 30, 2023
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release This item has been merged and will be released soon label Mar 30, 2023
@dreamorosi dreamorosi added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon confirmed The scope is clear, ready for implementation labels Mar 30, 2023
@dreamorosi dreamorosi moved this from Coming soon to Shipped in AWS Lambda Powertools for TypeScript Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility idempotency This item relates to the Idempotency Utility
Projects
None yet
2 participants