Open udoprog opened 4 years ago
Related: #191
I'm fine with presenting the set up for rate limiting differently (including having it be more directly optional), but I'd definitely like to include an out-of-the-box solution within the IRC crate if possible.
182 was fixed, but I didn't implement rate limiting using burst windows. As per the comment in #184, I raised the question whether this project should provide a built-in rate limiter at all or if we should encourage the user to use an external project like
leaky-bucket
(full disclosure: my project).The following is an example of how an external rate limiter is used for anyone who is curious. Unfortunately this hides a lot of utility functions of
Sender
(likesend_cap_req
) and it's not straight forward to make async functions likeacquire
below pluggable. async functions are not supported in traits, nor do we have existential types yet so the anonymous future can be named.The benefit however is that the rate limiter is an
async
function that can beawait
:ed at any point. You have full control over its configuration, use, and implementation. Rate limiting happens before the send is buffered which makes sure that the rest of your application is back pressured when necessary.