Skip to content

Override throttle rate for each endpoint - #993

Merged
TG1999 merged 3 commits into
aboutcode-org:mainfrom
TG1999:override_throttle
Nov 4, 2022
Merged

Override throttle rate for each endpoint#993
TG1999 merged 3 commits into
aboutcode-org:mainfrom
TG1999:override_throttle

Conversation

@TG1999

@TG1999 TG1999 commented Nov 3, 2022

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
@TG1999
TG1999 force-pushed the override_throttle branch from a00bb4e to f1b53d3 Compare November 3, 2022 19:57
@TG1999
TG1999 requested review from pombredanne and tdruez November 3, 2022 19:57
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
Comment thread vulnerablecode/settings.py Outdated
Comment thread vulnerabilities/throttling.py Outdated
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
Copy Markdown
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.

@TG1999 TG1999 Nov 4, 2022

Copy link
Copy Markdown
Contributor Author

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 <tushar.goel.dav@gmail.com>
@TG1999
TG1999 requested a review from tdruez November 4, 2022 12:04

@tdruez tdruez left a comment

Copy link
Copy Markdown
Contributor

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