allow :rate-limiter/rate to be floats, to have floating points rates (0.5 => 1 req every 2 seconds) #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for such a wonderful library — I am using this library so often when I hit external API endpoints.
Recently, I started using it to query the OpenAI API, which has token limits that often push the rate limit below one request per second. (I use thread pools via claypoole library to fire off parallel requests)
I found that it was super-easy to specify rate limits of less then 1 req/sec, merely by specifying floats less then 1.0. All I had to do was relax the spec to take
number?
instead ofint?
.PS: I haven't done any formalized or methodical testing, beyond just observation, but it works well enough for my purposes. (Before opening up this PR, I did some more measurements. A rate limit of 0.5 will fire 10 calls in 25 seconds. 0.33 will take 36 seconds. Good enough for me!)