Skip to content

Add Inequality Comparisons to Rules #701

Description

@gwlester

Is your feature request related to a problem? Please describe.

It would be helpful to be able to compare if something is GREATER_THAN or GREATER_THAN_OR_EQUAL to a value, e.g. if the current timestamp is greater a particular timestamp.

Describe the solution you'd like

Add the following to the comparison operators:

  • GREATER_THAN
  • GREATER_THAN_OR_EQUAL
  • LESS_THAN
  • LESS_THAN_OR_EQUAL
  • NOT_EQUAL

Alternatively, provide a documented way to add custom (i.e. user-supplied) conditions to the mapping_by_action set used in _match_by_action.

Describe alternatives you've considered

Additional context

Activity

  1. heitorlessa commented on Sep 25, 2021

    @heitorlessa
    Contributor

    Hey @gwlester - Thanks a lot for another feature request ;)

    I think a user supplied would be great here - it can unlock many other use cases customers might want.

    cc @risenberg-cyberark @whardier

  2. whardier commented on Sep 25, 2021

    @whardier
    Contributor

    I agree. I may attempt to patch that in. It would allow for some useful pre optimization as well (re.compile)

  3. gwlester commented on Sep 25, 2021

    @gwlester
    ContributorAuthor

    It would also be nice if the init took a logger and only created one if None was passed.

  4. gwlester commented on Sep 25, 2021

    @gwlester
    ContributorAuthor
  5. heitorlessa commented on Sep 25, 2021

    @heitorlessa
    Contributor
  6. gwlester commented on Sep 25, 2021

    @gwlester
    ContributorAuthor

    Ok, do you want a separate ticket to track "accept a Logger instance everywhere in 2.0"??

    Note -- that should not need a major revision roll since if the code looks like the following it is compatiable:

       def __init__ (self, logger=None):
           if logger == none:
               logger = logging.getLogger(__name__)

    Is equivalent.

  7. ran-isenberg commented on Sep 26, 2021

    @ran-isenberg
    Contributor

    @heitorlessa @gwlester When I created the feature, I didnt want to add too many actions right at the beginning but to start with sometihng that covers my basic needs. It's great that people are using it and we should add more actions.
    The only concern i have is regarding schema validation here for condition value, should we keep it as it is today - just check that it's not empty, or perhaps enforce more validation in case it's greater than (check int/float etc.). what do you think?

  8. ran-isenberg commented on Sep 26, 2021

    @ran-isenberg
    Contributor

    and bring your own logger should definitely be supported.

  9. heitorlessa commented on Sep 26, 2021

    @heitorlessa
    Contributor
  10. gwlester commented on Sep 26, 2021

    @gwlester
    ContributorAuthor
  11. gwlester commented on Sep 30, 2021

    @gwlester
    ContributorAuthor

    @heitorlessa @gwlester When I created the feature, I didnt want to add too many actions right at the beginning but to start with sometihng that covers my basic needs. It's great that people are using it and we should add more actions. The only concern i have is regarding schema validation here for condition value, should we keep it as it is today - just check that it's not empty, or perhaps enforce more validation in case it's greater than (check int/float etc.). what do you think?

    I'd not add any additional checking. An exception today causes a failed condition and that is enough.

  12. gwlester commented on Sep 30, 2021

    @gwlester
    ContributorAuthor

    I think the conditions need to be named clearer than I suggeted:

    • KEY_GREATER_THAN_VALUE
    • KEY_GREATER_THAN_OR_EQUAL_VALUE
    • KEY_LESS_THAN_VALUE
    • KEY_LESS_THAN_OR_EQUAL_VALUE
    • KEY_NOT_EQUAL_VALUE

    I will attempt to do a Pull Request for the above on 2021.10.01

  13. whardier commented on Sep 30, 2021

    @whardier
    Contributor

    I personally don't like how the exception is handled in the case where matching the value of False (which results in True) would match an exception. Not sure if this is intended to allow for exceptions to act this way by design and not disrupt the process.

  14. heitorlessa commented on Oct 1, 2021

    @heitorlessa
    Contributor

    @heitorlessa, done see Allow bring your own logger to Feature Flags #702

    Thanks a lot for that - I've just made the necessary changes and merged it.

  15. gwlester commented on Oct 1, 2021

    @gwlester
    ContributorAuthor

    @heitorlessa, will this one make next week's release?

  16. heitorlessa commented on Oct 1, 2021

    @heitorlessa
    Contributor

    If anyone could help getting the tests and merge conflicts in place by Monday EOD, yep it will ;-)

  17. gwlester commented on Oct 4, 2021

    @gwlester
    ContributorAuthor

    Tests and conflicts are done.

  18. gwlester commented on Oct 4, 2021

    @gwlester
    ContributorAuthor

    @heitorlessa -- I think this should have the label: status/staged-next-release

  19. added
    pending-releaseFix or implementation already in dev waiting to be released
    on Oct 4, 2021
  20. heitorlessa commented on Oct 4, 2021

    @heitorlessa
    Contributor
  21. heitorlessa commented on Oct 5, 2021

    @heitorlessa
    Contributor

    This is now available as part of today's 1.21.0 release -- Thank you for the contribution, credits given at the top ;)

    https://github.com/awslabs/aws-lambda-powertools-python/releases/tag/v1.21.0

  22. removed
    pending-releaseFix or implementation already in dev waiting to be released
    on Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions