brayniac / ratelimit

rust ratelimiter
Apache License 2.0
30 stars 5 forks source link

non-blocking rate-limiting #30

Open ma1ko opened 6 years ago

ma1ko commented 6 years ago

Currently the only way get a tocken is calling wait(). I need a non-blocking version (maybe get()) that tries to get a token, but if none is available the method returns with an error instead of waiting The use-case here is aborting operations if they are over their limit instead of waiting for new tokens.

Is this possible to implement?

brayniac commented 6 years ago

Yes. This is already implemented. .try_wait() and .try_wait_for(). Looks like the doc coverage isn't there for these. Will leave this open to address that.

ma1ko commented 6 years ago

Thanks! This is exactly what I need. I was just going through the documantation and couldn't find anything

brayniac commented 6 years ago

Awesome! I'll fix-up the documentation. Thanks for opening this!

On Sun, Apr 15, 2018, 10:18 AM ma1ko notifications@github.com wrote:

Thanks! This is exactly what I need. I was just going through the documantation and couldn't find anything

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/brayniac/ratelimit/issues/30#issuecomment-381422563, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ_jlyiDZDNi-udZ2GWtj0IGmhr83awOks5to4DLgaJpZM4TVX9n .