-
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
refactor(idempotent): Change UX to use a config class for non-persistence related features #306
Conversation
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.
WIP comments
Codecov Report
@@ Coverage Diff @@
## develop #306 +/- ##
===========================================
+ Coverage 99.54% 99.79% +0.24%
===========================================
Files 90 91 +1
Lines 3291 3340 +49
Branches 160 161 +1
===========================================
+ Hits 3276 3333 +57
+ Misses 10 5 -5
+ Partials 5 2 -3
Continue to review full report at Codecov.
|
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.
One small change for consistency across utilities (or
outside the constructor)
@@ -21,7 +21,7 @@ test: | |||
poetry run pytest --cache-clear tests/performance | |||
|
|||
coverage-html: | |||
poetry run pytest --cov-report html | |||
poetry run pytest -m "not perf" --cov-report=html |
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.
💯
class IdempotencyConfig: | ||
def __init__( |
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?
>>> def handler(event, context): | ||
>>> return {"StatusCode": 200} | ||
""" | ||
|
||
idempotency_handler = IdempotencyHandler(handler, event, context, persistence_store) | ||
idempotency_handler = IdempotencyHandler(handler, event, context, config or IdempotencyConfig(), persistence_store) |
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.
to make refactoring easier later, could you please (I can do too): Use or
logic outside the instantiation e.g. config = config or IdempotencyConfig()
nitpick: kwargs over args for refactoring too
self._cache: Optional[LRUDict] = None | ||
self.hash_function = None | ||
|
||
def configure(self, config: IdempotencyConfig) -> None: |
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.
I was thinking of having this in the constructor and change the way we call it within IdempotencyHandler, but honestly that can be done later - there are a few areas we'll need to refactor, and this will be an internal change either way, and in the worst case we're calling it Beta too, it'll be a minor change IF that.
I don't seem to have permissions to send a quick commit to fix what I asked, so I'm merging as-is, and sending a direct push to develop afterwards |
There’s an issue for enabling the new GitHub discussions - I just haven’t
had time to play with it yet. Then a board to unify accepted ideas etc
…On Fri, 5 Mar 2021 at 23:14, Michael Brewer ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In aws_lambda_powertools/utilities/idempotency/config.py
<#306 (comment)>
:
> +class IdempotencyConfig:
+ def __init__(
@heitorlessa <https://github.com/heitorlessa> should we add a mini
project for ideas?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZPQBH7ENPETI2WJSPHBWLTCFJUHANCNFSM4YS2X7OA>
.
|
…60 (#306) Bumps [mypy-boto3-dynamodb](https://github.com/youtype/mypy_boto3_builder) from 1.24.55.post1 to 1.24.60. - [Release notes](https://github.com/youtype/mypy_boto3_builder/releases) - [Commits](https://github.com/youtype/mypy_boto3_builder/commits) --- updated-dependencies: - dependency-name: mypy-boto3-dynamodb dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…owertools-python into develop * 'develop' of https://github.com/heitorlessa/aws-lambda-powertools-python: chore(deps-dev): bump mypy-boto3-dynamodb from 1.24.55.post1 to 1.24.60 (#306)
…60 (#306) Bumps [mypy-boto3-dynamodb](https://github.com/youtype/mypy_boto3_builder) from 1.24.55.post1 to 1.24.60. - [Release notes](https://github.com/youtype/mypy_boto3_builder/releases) - [Commits](https://github.com/youtype/mypy_boto3_builder/commits) --- updated-dependencies: - dependency-name: mypy-boto3-dynamodb dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…60 (#306) Bumps [mypy-boto3-dynamodb](https://github.com/youtype/mypy_boto3_builder) from 1.24.55.post1 to 1.24.60. - [Release notes](https://github.com/youtype/mypy_boto3_builder/releases) - [Commits](https://github.com/youtype/mypy_boto3_builder/commits) --- updated-dependencies: - dependency-name: mypy-boto3-dynamodb dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…60 (#306) (#289) Bumps [mypy-boto3-dynamodb](https://github.com/youtype/mypy_boto3_builder) from 1.24.55.post1 to 1.24.60. - [Release notes](https://github.com/youtype/mypy_boto3_builder/releases) - [Commits](https://github.com/youtype/mypy_boto3_builder/commits) --- updated-dependencies: - dependency-name: mypy-boto3-dynamodb dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…60 (#306) Bumps [mypy-boto3-dynamodb](https://github.com/youtype/mypy_boto3_builder) from 1.24.55.post1 to 1.24.60. - [Release notes](https://github.com/youtype/mypy_boto3_builder/releases) - [Commits](https://github.com/youtype/mypy_boto3_builder/commits) --- updated-dependencies: - dependency-name: mypy-boto3-dynamodb dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…60 (#306) (#92) Bumps [mypy-boto3-dynamodb](https://github.com/youtype/mypy_boto3_builder) from 1.24.55.post1 to 1.24.60. - [Release notes](https://github.com/youtype/mypy_boto3_builder/releases) - [Commits](https://github.com/youtype/mypy_boto3_builder/commits) --- updated-dependencies: - dependency-name: mypy-boto3-dynamodb dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Description of changes:
UX for idempotent decorator changes from:
to
All other changes include:
coverage-html
pragma: no cover
for old uncovered codeChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.