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
class Object
trait Matchable
class Any

Value members

Abstract methods

def apply[R, E, A](task: ZIO[R, E, A]): ZIO[R, E, A]

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.

Concrete methods

def toPolicy: Policy[Any]