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(commons): centralize cold start heuristic #547

Merged
merged 5 commits into from
Feb 16, 2022

Conversation

dreamorosi
Copy link
Contributor

Description of your changes

This PR introduces a new Utility class in the @aws-lambda-powertools/commons package. This class is designed to be extended by other Powertools utilities that will inherit its shared methods.

In this iteration the Utility class brings a centralised cold start heuristic to be shared by all core packages.

The changes in this PR have already been discussed in an internal RFC document reviewed by at least two other maintainers as per CONTRIBUTING guidelines.

How to verify this change

Clone the repo & check newly introduced unit tests.
Also check the JSDoc documentation written in the class file.

Related issues, RFCs

#484

PR status

Is this ready for review?: YES
Is it a breaking change?: NO

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
  • 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
  • The PR title follows the conventional commit semantics

Breaking change checklist

N/A


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

Copy link
Contributor

@ijemmy ijemmy left a comment

Choose a reason for hiding this comment

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

Only typo and grammar. This rest looks good.

packages/commons/src/Utility.ts Outdated Show resolved Hide resolved
packages/commons/src/Utility.ts Outdated Show resolved Hide resolved
@dreamorosi dreamorosi requested a review from ijemmy February 11, 2022 17:28
@dreamorosi dreamorosi requested a review from flochaz February 15, 2022 09:24

});

test('when called multiple times on a child class, it returns true the first time, then false afterwards', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What would be the use case of testing the functionality from a child class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other utilities (Tracer, Logger, etc.) will extend this Utility class and use it just like in this test case. I agree that it might be a little redundant but adding one test case was easier/faster than build+pack the new version of commons & install it in another package to test it.

Copy link
Contributor

@saragerion saragerion left a comment

Choose a reason for hiding this comment

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

LGTM!

@dreamorosi dreamorosi merged commit 4e4091f into main Feb 16, 2022
@dreamorosi dreamorosi deleted the feat/commons/centralize_cold_start branch February 16, 2022 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants