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(idempotent): Include function name in the idempotent key #326

Merged
merged 9 commits into from
Mar 12, 2021

Conversation

michaelbrewer
Copy link
Contributor

@michaelbrewer michaelbrewer commented Mar 11, 2021

Issue #, if available:
#318

Description of changes:

Prefix the hashed_idempotency_key with the context function name:

f"{context.function_name}#{self._generate_hash(data)}"

NOTE: Rather than hash this prefix, I kept it in the clear to make debugging a little easier and I did not make
this configurable, as this makes sense as the default

HOWEVER: You MIGHT get edge cases where the function name has been changed while keeping an existing datastore

Checklist

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

@michaelbrewer michaelbrewer marked this pull request as draft March 11, 2021 06:56
@michaelbrewer
Copy link
Contributor Author

@heitorlessa what do you think of this ?

Michael Brewer and others added 2 commits March 10, 2021 23:53
@michaelbrewer michaelbrewer marked this pull request as ready for review March 11, 2021 09:09
@michaelbrewer michaelbrewer changed the title feat(idempotent): Prefix key with function name feat(idempotent): Add option to include function name in the idempotent key Mar 12, 2021
@heitorlessa heitorlessa added area/utilities feature New feature or functionality labels Mar 12, 2021
@heitorlessa heitorlessa added this to the 1.12.0 milestone Mar 12, 2021
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

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

Great, thanks!!! Only change here is that we shouldn't add this extra parameter to include function_name, but make it the default.

Because we're in Beta this won't cause any distress, and due to the fact changing a Function name is not possible from an API perspective - IaC triggers a replacement instead.

aws_lambda_powertools/utilities/idempotency/config.py Outdated Show resolved Hide resolved
tests/functional/idempotency/test_idempotency.py Outdated Show resolved Hide resolved
@michaelbrewer michaelbrewer changed the title feat(idempotent): Add option to include function name in the idempotent key feat(idempotent): Include function name in the idempotent key Mar 12, 2021
Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the changes @michaelbrewer, as always ;)

Added a note to update docs to emphasize you can now use a single DDB table to store idempotence state if you wish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants