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

Override throttle rate for each endpoint #993

Merged
merged 3 commits into from
Nov 4, 2022

Conversation

TG1999
Copy link
Contributor

@TG1999 TG1999 commented Nov 3, 2022

No description provided.

Signed-off-by: Tushar Goel <[email protected]>
vulnerablecode/settings.py Outdated Show resolved Hide resolved
Comment on lines 38 to 63
class VulnerablePackagesAPIThrottle(StaffUserRateThrottle):
scope = "vulnerable_packages"


class BulkSearchPackagesAPIThrottle(StaffUserRateThrottle):
scope = "bulk_search_packages"


class PackagesAPIThrottle(StaffUserRateThrottle):
scope = "packages"


class VulnerabilitiesAPIThrottle(StaffUserRateThrottle):
scope = "vulnerabilities"


class AliasesAPIThrottle(StaffUserRateThrottle):
scope = "aliases"


class CPEAPIThrottle(StaffUserRateThrottle):
scope = "cpes"


class BulkSearchCPEAPIThrottle(StaffUserRateThrottle):
scope = "bulk_search_cpes"
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no better way to do this? It looks like a lot of duplication here.

Copy link
Contributor Author

@TG1999 TG1999 Nov 4, 2022

Choose a reason for hiding this comment

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

I have now used ScopeRatedThrottling, please see if it looks good

Signed-off-by: Tushar Goel <[email protected]>
@TG1999 TG1999 requested a review from tdruez November 4, 2022 12:04
Copy link
Contributor

@tdruez tdruez left a comment

Choose a reason for hiding this comment

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

Much better!

@TG1999 TG1999 merged commit eb6e935 into aboutcode-org:main Nov 4, 2022
@TG1999 TG1999 deleted the override_throttle branch November 4, 2022 12:47
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