Skip to content

Conversation

michaelbrewer
Copy link
Contributor

@michaelbrewer michaelbrewer commented Dec 4, 2021

Issue #, if available:

Description of changes:

Include the callable function name in the generated idempotent key

Checklist

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

@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 4, 2021
@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2021

Codecov Report

Merging #869 (2cd2b3b) into develop (81fc02e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #869   +/-   ##
========================================
  Coverage    99.90%   99.90%           
========================================
  Files          118      118           
  Lines         5125     5126    +1     
  Branches       571      571           
========================================
+ Hits          5120     5121    +1     
  Misses           2        2           
  Partials         3        3           
Impacted Files Coverage Δ
...ws_lambda_powertools/utilities/idempotency/base.py 100.00% <100.00%> (ø)
...wertools/utilities/idempotency/persistence/base.py 99.37% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81fc02e...2cd2b3b. Read the comment docs.

@@ -124,7 +125,7 @@ def __init__(self):
self._cache: Optional[LRUDict] = None
self.hash_function = None

def configure(self, config: IdempotencyConfig) -> None:
def configure(self, config: IdempotencyConfig, function_name: str) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@heitorlessa - should this be optional? or required?

Copy link
Contributor

Choose a reason for hiding this comment

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

Optional. Only because it's a public method and we have no way of knowing if someone took a dependency on it via tests or something - if they did, we will break them and take another release to fix it

@heitorlessa heitorlessa added the bug Something isn't working label Dec 6, 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.

two minor changes: 1/ make function_name optional as we don't know who ended up taking a dependency on that public method (Hyrum's Law), 2/ use f-string to optimize memory and a CPU cycle as str is more expensive in Python than usual

@@ -124,7 +125,7 @@ def __init__(self):
self._cache: Optional[LRUDict] = None
self.hash_function = None

def configure(self, config: IdempotencyConfig) -> None:
def configure(self, config: IdempotencyConfig, function_name: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional. Only because it's a public method and we have no way of knowing if someone took a dependency on it via tests or something - if they did, we will break them and take another release to fix it

make configure backwards compatible
resolve the full function name ahead of time
@michaelbrewer
Copy link
Contributor Author

@heitorlessa @cakepietoast - i have pushed recommended changes.

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 Mike!

@heitorlessa heitorlessa changed the title fix(idempotency): include function name in hash fix(idempotency): include decorated fn name in hash Dec 7, 2021
@heitorlessa heitorlessa merged commit 5cb9852 into aws-powertools:develop Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants