-
Notifications
You must be signed in to change notification settings - Fork 421
refactor(idempotent): Change UX to use a config class for non-persistence related features #306
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
Merged
heitorlessa
merged 14 commits into
aws-powertools:develop
from
gyft:refactoring-idempotent-ux
Mar 5, 2021
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dfb5b0f
refactor(idempotent): Create a config class
michaelbrewer b482152
fix: Reanable test
michaelbrewer 2174b91
Merge branch 'develop' into refactoring-idempotent-ux
michaelbrewer 2512cda
chore: Some refactoring
michaelbrewer 131bde4
docs: Update docs
michaelbrewer e74a489
Merge branch 'develop' into refactoring-idempotent-ux
michaelbrewer 07e8a06
docs(batch): add example on how to integrate with sentry.io (#308)
heitorlessa e2c96eb
Merge branch 'develop' into refactoring-idempotent-ux
michaelbrewer 7d4304b
chore(docs): Update the docs
michaelbrewer 0fc4ee2
fix(tests): Fix coverage-html and various update
michaelbrewer eb4787c
refactor: Change back to configure
michaelbrewer b041f3f
chore: Hide missing code coverage
michaelbrewer 8c2350e
chore: bump ci
michaelbrewer 1254b06
chore: bump ci
michaelbrewer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class IdempotencyConfig: | ||
def __init__( | ||
self, | ||
event_key_jmespath: str = "", | ||
payload_validation_jmespath: str = "", | ||
raise_on_no_idempotency_key: bool = False, | ||
expires_after_seconds: int = 60 * 60, # 1 hour default | ||
use_local_cache: bool = False, | ||
local_cache_max_items: int = 256, | ||
hash_function: str = "md5", | ||
): | ||
""" | ||
Initialize the base persistence layer | ||
|
||
Parameters | ||
---------- | ||
event_key_jmespath: str | ||
A jmespath expression to extract the idempotency key from the event record | ||
payload_validation_jmespath: str | ||
A jmespath expression to extract the payload to be validated from the event record | ||
raise_on_no_idempotency_key: bool, optional | ||
Raise exception if no idempotency key was found in the request, by default False | ||
expires_after_seconds: int | ||
The number of seconds to wait before a record is expired | ||
use_local_cache: bool, optional | ||
Whether to locally cache idempotency results, by default False | ||
local_cache_max_items: int, optional | ||
Max number of items to store in local cache, by default 1024 | ||
hash_function: str, optional | ||
Function to use for calculating hashes, by default md5. | ||
""" | ||
self.event_key_jmespath = event_key_jmespath | ||
self.payload_validation_jmespath = payload_validation_jmespath | ||
self.raise_on_no_idempotency_key = raise_on_no_idempotency_key | ||
self.expires_after_seconds = expires_after_seconds | ||
self.use_local_cache = use_local_cache | ||
self.local_cache_max_items = local_cache_max_items | ||
self.hash_function = hash_function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - Hopefully when 3.6 is EOL we'll be able to move to dataclasses to make this easier too, including having a generic Config that auto-discovers env vars based on config option name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heitorlessa should we add a mini project for ideas?