sethvargo / go-limiter

A supersonic rate limiting package for Go with HTTP middleware.
Apache License 2.0
555 stars 40 forks source link

Take many tokens #38

Closed FZambia closed 1 year ago

FZambia commented 1 year ago

Hello, many thanks for the library with a great performance and nice API.

It's written in readme that:

While go-limit supports rate limiting at the HTTP layer, it can also be used to rate limit literally anything.

I am researching a rate limiting based on traffic read from the socket. In this case I need to take the number of tokens which is equal to the length of data read from the socket. It seems not possible with the current package API. Is it good idea to extend API in this way or it's out of scope?

sethvargo commented 1 year ago

Hi @FZambia - the library is hyper optimized for taking a single entry from a leaky bucket. If you want to take multiple items from a bucket, I would recommend looking at a different library, including the one in x.

FZambia commented 1 year ago

I see, thank you