Allows the user to await
on requests that have a wider width than the
burstSize
specified in AsyncMeter.
Allows the user to await
on requests that have a wider width than the
burstSize
specified in AsyncMeter.
WARNING: this means that you are able to arbitrarily exceed your
burstSize
setting, so it violates the contract that you never exceed
burstSize
within a given burstDuration
. Also, because of the
implementation, it consumes more than one slot from maxWaiters
.
Creates an AsyncMeter that has a maximum burst size of burstSize
over
burstDuration
, and no more than maxWaiters
waiters.
Creates an AsyncMeter that has a maximum burst size of burstSize
over
burstDuration
, and no more than maxWaiters
waiters. The burstSize
permits will be disbursed on a regular schedule, so that they aren't
bunched up.
Creates an AsyncMeter that has a maximum burst size of burstSize
over
burstDuration
, and an unbounded number of waiters.
Creates an AsyncMeter that has a maximum burst size of burstSize
over
burstDuration
, and an unbounded number of waiters. The burstSize
permits will be disbursed on a regular schedule, so that they aren't
bunched up.
WARNING: Only use an unbounded number of waiters when some other aspect of your implementation already bounds the number of waiters. If there is no other bound, the waiters can use up your process' resources.
Creates an AsyncMeter that allows smoothed out permits
per
second, and has a maximum burst size of permits
over one second.
Creates an AsyncMeter that allows smoothed out permits
per
second, and has a maximum burst size of permits
over one second.
This is equivalent to AsyncMeter.newMeter(permits, 1.second, maxWaiters)
.
Creates an AsyncMeter that allows smoothed out permits
per second,
and has a maximum burst size of 1 permit over 1.second / permits
.
Creates an AsyncMeter that allows smoothed out permits
per second,
and has a maximum burst size of 1 permit over 1.second / permits
.
This method produces AsyncMeters that might be placed before an external API forcing a rate limit over a one second. For example, the following meter rate limits its callers to make sure no more than 8 QPS is sent at any point of time.
val meter = AsyncMeter.perSecondLimited(8, 100)
This is equivalent to AsyncMeter.newMeter(1, 1.second / permits, maxWaiters)
.