Is there a way in Rust with Governor, to create a RateLimiter for 10/10s?
You can create the Quota:
let q10 = Quota::with_period(Duration::from_secs(10))
.unwrap()
.allow_burst(NonZeroU32::new(10).unwrap());
However this only replenishes one every 10seconds.
And there doesn't seem to be a way to completely replenish a quota every some seconds correct? The only way seems to be replacing the RateLimiter completely each 10 seconds.
I do not believe governor can do what you want. The ratelimit crate seems to, though.
let ratelimiter = Ratelimiter::builder(10, Duration::from_secs(10))
.max_tokens(10)
.build()
.unwrap();
This snippet will create a limiter that allows 10 requests every 10 seconds, with a max burst of 10. This means that you can make 10 requests in quick succession but must wait 10 seconds before sending any more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With