Skip to content
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

feat(idempotency): implement IdempotencyHandler #1416

Merged
merged 4 commits into from
Apr 25, 2023
Merged

feat(idempotency): implement IdempotencyHandler #1416

merged 4 commits into from
Apr 25, 2023

Conversation

am29d
Copy link
Contributor

@am29d am29d commented Apr 24, 2023

This is a small PR for the #1303 implementation. Most of the IdempotencyHandler was already implemented and aligned with decorator and function wrapper. In addition, I have added a try mechanism to mitigate rare race conditions error, similar to python implementation.

Description of your changes

How to verify this change

Related issues, RFCs

Issue number: closes #1303

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Apr 24, 2023
@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Apr 24, 2023
@dreamorosi dreamorosi self-requested a review April 24, 2023 14:30
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, I just would like to address one return type and remove a ts-ignore before merging

* In most cases we can retry successfully on this exception.
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we merge, can we fix this return type and remove the comment?

Based on what I see, we either need to change the return type to Promise<U | undefined> or make sure that the function returns something in the catch block when the if statement is skipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this is weird construct we have there. Adding undefined to the Promise would leak it further to makeIdempotentFunction and also higher to the user api, which I'd like to avoid. TS complains about missing return statement outside of the for-loop. But adding a statement makes it impossible to test, because this return statement is unreachable. I have added a throw with coverage ignore.

@dreamorosi dreamorosi self-requested a review April 25, 2023 18:50
@dreamorosi dreamorosi merged commit f2ebf08 into aws-powertools:main Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature PRs that introduce new features or minor changes size/L PRs between 100-499 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: implement IdempotencyHandler
2 participants