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
Along with request.limited, add another attribute like request.limited_until or request.limited_expires that lets the view know how long until all relevant ratelimit windows expire.
A couple of examples:
@ratelimit(rate='10/m') # this window expires in 22 secondsdefone_ratelimit(request):
request.limited# Truerequest.limited_until# 22@ratelimit(rate='10/m') # this window expires in 31 seconds@ratelimit(rate='100/h') # this limit has NOT been hitdefburst_limit(request):
request.limited_until# 31@ratelimit(rate='10/m') # this window expires in 19 seconds@ratelimit(rate='100/h') # this limit HAS been hit and expires in 1421 secondsdeftrue_limit(request):
request.limited_until# 1421
After #163 and #164, it should be relatively straightforward to replace the usage of is_ratelimited in @ratelimit with the more powerful get_usage_count, which will make this much easier.
I kind of prefer returning seconds so we don't have to deal with datetime math, which will probably be slightly more expensive, until/unless it's time to format the date. So limited_for or limited_seconds is probably a better name than limited_until. I like attempted keeping the name similar to limited, but request.retry_after could also work.
The text was updated successfully, but these errors were encountered:
Along with
request.limited
, add another attribute likerequest.limited_until
orrequest.limited_expires
that lets the view know how long until all relevant ratelimit windows expire.A couple of examples:
After #163 and #164, it should be relatively straightforward to replace the usage of
is_ratelimited
in@ratelimit
with the more powerfulget_usage_count
, which will make this much easier.I kind of prefer returning seconds so we don't have to deal with datetime math, which will probably be slightly more expensive, until/unless it's time to format the date. So
limited_for
orlimited_seconds
is probably a better name thanlimited_until
. I like attempted keeping the name similar tolimited
, butrequest.retry_after
could also work.The text was updated successfully, but these errors were encountered: