class RateLimited

Properties

protected RateLimiter $limiter

The rate limiter instance.

protected string $limiterName

The name of the rate limiter.

protected string|null $storeName

The rate limiter store that should be used.

DateTimeInterface|int|null $releaseAfter

The number of seconds before a job should be available again if the limit is exceeded.

protected int $releasePadding

The extra seconds added to the rate limiter's retry delay.

bool $shouldRelease

Indicates if the job should be released if the limit is exceeded.

Methods

__construct(UnitEnum|string $limiterName)

Create a new middleware instance.

mixed
handle(mixed $job, callable $next)

Process the job.

mixed
handleJob(mixed $job, callable $next, array $limits, Limiter $limiter)

Handle a rate limited job.

releaseAfter(DateTimeInterface|int $releaseAfter)

Set the delay (in seconds) to release the job back to the queue.

releasePadding(int $seconds)

Set the extra seconds added to the rate limiter's retry delay.

dontRelease()

Do not release the job back to the queue if the limit is exceeded.

store(UnitEnum|string $store)

Specify the rate limiter store that should be used.

array
__sleep()

Prepare the object for serialization.

void
__wakeup()

Prepare the object after unserialization.

Details

at line 54
__construct(UnitEnum|string $limiterName)

Create a new middleware instance.

Parameters

UnitEnum|string $limiterName

at line 65
mixed handle(mixed $job, callable $next)

Process the job.

Parameters

mixed $job
callable $next

Return Value

mixed

at line 92
protected mixed handleJob(mixed $job, callable $next, array $limits, Limiter $limiter)

Handle a rate limited job.

Parameters

mixed $job
callable $next
array $limits
Limiter $limiter

Return Value

mixed

at line 111
RateLimited releaseAfter(DateTimeInterface|int $releaseAfter)

Set the delay (in seconds) to release the job back to the queue.

Parameters

DateTimeInterface|int $releaseAfter

Return Value

RateLimited

at line 123
RateLimited releasePadding(int $seconds)

Set the extra seconds added to the rate limiter's retry delay.

Parameters

int $seconds

Return Value

RateLimited

at line 139
RateLimited dontRelease()

Do not release the job back to the queue if the limit is exceeded.

Return Value

RateLimited

at line 153
RateLimited store(UnitEnum|string $store)

Specify the rate limiter store that should be used.

Parameters

UnitEnum|string $store

Return Value

RateLimited

at line 163
array __sleep()

Prepare the object for serialization.

Return Value

array

at line 177
void __wakeup()

Prepare the object after unserialization.

Return Value

void