interface LimiterInterface

Methods

Reservation
reserve(int$tokens =1,float|null$maxTime =null)

Waits until the required number of tokens is available.

RateLimit
consume(int$tokens =1)

Use this method if you intend to drop if the required number of tokens is unavailable.

void
reset()

Resets the limit.

Details

Reservation reserve(int$tokens =1,float|null$maxTime =null)

Waits until the required number of tokens is available.

The reserved tokens will be taken into account when calculating future token consumptions. Do not use this method if you intend to skip this process.

Parameters

int $tokens the number of tokens required
float|null $maxTime maximum accepted waiting time in seconds

Return Value

Reservation

Exceptions

MaxWaitDurationExceededException if $maxTime is set and the process needs to wait longer than its value (in seconds)
ReserveNotSupportedException if this limiter implementation doesn't support reserving tokens
InvalidArgumentException if $tokens is larger than the maximum burst size

RateLimit consume(int$tokens =1)

Use this method if you intend to drop if the required number of tokens is unavailable.

Parameters

int $tokens the number of tokens required

Return Value

RateLimit

void reset()

Resets the limit.

Return Value

void