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

Add rate limit to confighttp #1

Merged
merged 1 commit into from
Nov 6, 2023
Merged

Conversation

foadnh
Copy link

@foadnh foadnh commented Sep 25, 2023

Ticket

HLDD

For tests, I followed the same structure as other tests in the package (very similar to ServerAuth tests).

@foadnh foadnh requested a review from mallyx3 September 25, 2023 06:03
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
err := limiter.Take(r.Context(), r.URL.Path, r.Header)
if err != nil {
http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests)
Copy link

Choose a reason for hiding this comment

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

Do we want to support a condition where err is not nil but its also not a rate limited error either?
Would we want to be able to surface other runtime errors via the interceptor or should we surface it another way?

Copy link
Author

Choose a reason for hiding this comment

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

I also thought about it. in-memory limiter, which is a backoff limiter, will not return any errors other than rate-limited. So I was wondering if I need an extra condition in here?

Copy link

Choose a reason for hiding this comment

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

Hmm the in memory limiter could still return other errors. Like for instance there could be runtime errors from misconfiguration (ie a default limiter not being set for a limiter type).

@foadnh foadnh merged commit a397030 into main Nov 6, 2023
@foadnh foadnh deleted the foadnh-add-rate-limit-to-confighttp branch November 6, 2023 05:20
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