class RateLimited

Properties

protected RateLimiter $limiter

The rate limiter instance.

protected string $limiterName

The name of the rate limiter.

DateTimeInterface|int|null $releaseAfter

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

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)

Handle a rate limited job.

releaseAfter(DateTimeInterface|int $releaseAfter)

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

dontRelease()

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

int
getTimeUntilNextRetry(string $key)

Get the number of seconds that should elapse before the job is retried.

array
__sleep()

Prepare the object for serialization.

__wakeup()

Prepare the object after unserialization.

Details

at line 42
__construct(UnitEnum|string $limiterName)

Create a new middleware instance.

Parameters

UnitEnum|string $limiterName

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

Process the job.

Parameters

mixed $job
callable $next

Return Value

mixed

at line 84
protected mixed handleJob(mixed $job, callable $next, array $limits)

Handle a rate limited job.

Parameters

mixed $job
callable $next
array $limits

Return Value

mixed

at line 102
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 112
RateLimited dontRelease()

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

Return Value

RateLimited

at line 122
protected int getTimeUntilNextRetry(string $key)

Get the number of seconds that should elapse before the job is retried.

Parameters

string $key

Return Value

int

at line 130
array __sleep()

Prepare the object for serialization.

Return Value

array

at line 142
__wakeup()

Prepare the object after unserialization.