bandwidth-throttle / token-bucket

Implementation of the Token Bucket algorithm in PHP.
Do What The F*ck You Want To Public License
503 stars 77 forks source link

Tokens left #7

Closed ala747 closed 7 years ago

ala747 commented 7 years ago

Hi!

Is there any way to know/access to how many tokens are left until reach the time limit?

Thanks!

malkusch commented 7 years ago

No, I didn't implement that. But if you convince me that this is a useful feature I would add that. What's your exact use case?

ala747 commented 7 years ago

Hi, Markus. Thank you very much for your quick answer.

Well, I don't know if my case would be a widely extended one.

I'm implementing your great library to throttle an API. I'm using a monthly based rate and, as it is a relatively long time, I would like to give the client a way to "ask" us how many requests he has left to avoid "surprises", giving him the opportunity to ask us to extend his limit before he hits it.

What do you think? Makes sense for you?

malkusch commented 7 years ago

It makes sense. You'll get it.

ala747 commented 7 years ago

Thank you! Don't hesitate to ping me if I can help you