trait RateLimiter
Limits the number of calls to a resource to a maximum amount in some interval
Uses a token bucket algorithm
Note that only the moment of starting the effect is rate limited: the number of concurrent executions is not bounded. For that you may use a Bulkhead
Calls are queued up in an unbounded queue until capacity becomes available.
- Companion:
- object
Value members
Abstract methods
Execute the task with RateLimiter protection
Execute the task with RateLimiter protection
The effect returned by this method can be interrupted, which is handled as follows:
- If the task is still waiting in the rate limiter queue, it will not start execution. It will also not count for the rate limiting or hold back other uninterrupted queued tasks.
- If the task has already started executing, interruption will interrupt the task and will complete when the task's interruption is complete.
- Value parameters:
- task
Task to execute. When the rate limit is exceeded, the call will be postponed.