jhurliman / node-rate-limiter

A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled
MIT License
1.5k stars 132 forks source link

Add non-leaky bucket implementation #14

Closed devmattrick closed 9 years ago

devmattrick commented 9 years ago

Hello, I think it may be a good idea to include a non-leaky bucket implementation. Instead of it eventually doing the intended action, just block the action altogether.

jhurliman commented 9 years ago

@mattrick16 that sounds like a great idea. I won't have time to do the implementation by myself in the near future, but if anyone does start working on it please let me know in this ticket.

jhurliman commented 9 years ago

Actually, this should already be possible with tryRemoveTokens. It's a synchronous method that will return false if the requested number of tokens could not be removed.