You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The limiter#Limiter returns two kinds of errors from WaitN():
returnfmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, burst)
returnfmt.Errorf("rate: Wait(n=%d) would exceed context deadline", n)
In the case of an HTTP request limit, I would ideally return a 429 Too Many Requests for each, but there are other errors that can be returned, like a context cancellation. It would be convenient to have an error type exposed in the package API that can be used with errors.As/errors.Is to see if the limiter has rejected the request.
The text was updated successfully, but these errors were encountered:
When reading this code, I mistakenly navigated in golang.org/x/time/rate and read some of the WaitN implementation there. That's where the errors described above are generated. I think it wouldn't be a great practice for dskit to inspect the contents of those errors in order to return two different sentinel errors. I'll file an issue with that package instead.
The
limiter#Limiter
returns two kinds of errors fromWaitN()
:In the case of an HTTP request limit, I would ideally return a
429 Too Many Requests
for each, but there are other errors that can be returned, like a context cancellation. It would be convenient to have an error type exposed in the package API that can be used witherrors.As
/errors.Is
to see if the limiter has rejected the request.The text was updated successfully, but these errors were encountered: