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

Erl call take if no erl config #59

Merged
merged 5 commits into from
Apr 12, 2024
Merged

Conversation

pubalokta
Copy link

Description

This PR includes 3 minor fixes:

  • If calling takeElevated for a bucket with no elevated configuration, it allows the call to takeElevated.lua but indicating ERL is disabled so it doesn't attempt to activate it. It
  • Adding takeElevated to client.js
  • takeElevated now returns the quota left in the bucket after activating ERL instead of the quota previous to activating it, to make it easier for the clients to understand it.

Testing

Describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests.

Also include details of the environment this PR was developed in (language/platform/browser version).

  • [ x ] This change adds test coverage for new/changed/fixed functionality

Checklist

  • [ x ] I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • [ x ] The correct base branch is being used, if not the default branch

@pubalokta pubalokta requested a review from a team as a code owner April 11, 2024 14:17
@@ -8,6 +8,7 @@ local erl_bucket_size = tonumber(ARGV[7])
local erl_activation_period_seconds = tonumber(ARGV[8])
local erl_quota_amount = tonumber(ARGV[9])
local erl_quota_expiration_epoch = tonumber(ARGV[10])
local is_erl_enabled = ARGV[11] == "true" and true or false
Copy link
Author

Choose a reason for hiding this comment

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

just in case, this is the ternary operator in lua, similar to
condition ? true : false

return callback(valError)
let isERLEnabledForBucket = true;
const valERLConfigError = validateConfigIsForElevatedBucket(key, bucketKeyConfig)
if (valERLConfigError) {
Copy link

Choose a reason for hiding this comment

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

is this semantically different than going down the take() function at this point?

Copy link

Choose a reason for hiding this comment

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

sorry, i know there was a slack thread on this but I found it hard to parse 😅

Copy link

Choose a reason for hiding this comment

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

I suppose the return values are different?

Copy link
Author

Choose a reason for hiding this comment

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

yes. If we make it go the take(), we will only be using takeElevated.lua for buckets with elevated limits configuration and we'll always depend on both scripts.
This way we'll be making sure takeElevated.lua works for both scenarios and in the future we'll be able to join them in a single method if we wish to do so.

Copy link

@LeweyM LeweyM left a comment

Choose a reason for hiding this comment

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

lgtm with minor suggestion 👍

pubalokta and others added 2 commits April 12, 2024 10:01
Co-authored-by: LeweyM <36539330+LeweyM@users.noreply.github.com>
@pubalokta pubalokta merged commit e3ea1db into master Apr 12, 2024
2 checks passed
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.

2 participants