boinkor-net / governor

A rate-limiting library for Rust (f.k.a. ratelimit_meter)
https://github.com/boinkor-net/governor
MIT License
550 stars 43 forks source link

How to know RateLimiter inner Quota #200

Open baoyachi opened 1 year ago

antifuchs commented 1 year ago

That's a tricky question: To save space, the RateLimiter struct doesn't retain a reference to the Quota (instead, representing the quota in its Gcra elements T and Tau. If you wish to refer back to the Quota, it's probably best to hold on to the Quota that was used to create the rate limiter; if that's not an option for you, I think it might be possible to "decompile" the Gcra elements back into a quota. Is that what you're asking for?

baoyachi commented 1 year ago

That's a tricky question: To save space, the RateLimiter struct doesn't retain a reference to the Quota (instead, representing the quota in its Gcra elements T and Tau. If you wish to refer back to the Quota, it's probably best to hold on to the Quota that was used to create the rate limiter; if that's not an option for you, I think it might be possible to "decompile" the Gcra elements back into a quota. Is that what you're asking for?

Yes,you are right. I need it.