class ThrottlesExceptions

Properties

protected string|null $key

The developer specified key that the rate limiter should use.

protected bool $byJob

Indicates whether the throttle key should use the job's UUID.

protected Throwable): int|int $retryAfterMinutes

The number of minutes to wait before retrying the job after an exception.

protected ?callable $reportCallback

The callback that determines if the exception should be reported.

protected ?callable $whenCallback

The callback that determines if rate limiting should apply.

protected callable[] $deleteWhenCallbacks

The callbacks that determine if the job should be deleted.

protected callable[] $failWhenCallbacks

The callbacks that determine if the job should be failed.

protected string $prefix

The prefix of the rate limiter key.

protected string|null $storeName

The rate limiter store that should be used.

Methods

__construct(int $maxAttempts = 10, int $decaySeconds = 600)

Create a new middleware instance.

mixed
handle(mixed $job, callable $next)

Process the job.

when(callable $callback)

Specify a callback that should determine if rate limiting behavior should apply.

deleteWhen(callable|string $callback)

Add a callback that should determine if the job should be deleted.

failWhen(callable|string $callback)

Add a callback that should determine if the job should be failed.

bool
shouldDelete(Throwable $throwable)

Determine if the job should be deleted for the given exception.

bool
shouldFail(Throwable $throwable)

Determine if the job should be failed for the given exception.

withPrefix(string $prefix)

Set the prefix of the rate limiter key.

store(UnitEnum|string $store)

Specify the rate limiter store that should be used.

backoff(Closure|int $backoff)

Specify the number of minutes a job should be delayed when it is released (before it has reached its max exceptions).

int
getTimeUntilNextRetryAfterException(Throwable $throwable)

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

string
getKey(mixed $job)

Get the key associated with the rate limiter.

by(string $key)

Set the value that the rate limiter should be keyed by.

byJob()

Indicate that the throttle key should use the job's UUID.

report(callable|null $callback = null)

Report exceptions and optionally specify a callback that determines if the exception should be reported.

Details

at line 80
__construct(int $maxAttempts = 10, int $decaySeconds = 600)

Create a new middleware instance.

Parameters

int $maxAttempts

the maximum number of attempts allowed before rate limiting applies

int $decaySeconds

the number of seconds until the maximum attempts are reset

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

Process the job.

Parameters

mixed $job
callable $next

Return Value

mixed

Exceptions

Throwable

at line 145
ThrottlesExceptions when(callable $callback)

Specify a callback that should determine if rate limiting behavior should apply.

Parameters

callable $callback

Return Value

ThrottlesExceptions

at line 155
ThrottlesExceptions deleteWhen(callable|string $callback)

Add a callback that should determine if the job should be deleted.

Parameters

callable|string $callback

Return Value

ThrottlesExceptions

at line 167
ThrottlesExceptions failWhen(callable|string $callback)

Add a callback that should determine if the job should be failed.

Parameters

callable|string $callback

Return Value

ThrottlesExceptions

at line 179
protected bool shouldDelete(Throwable $throwable)

Determine if the job should be deleted for the given exception.

Parameters

Throwable $throwable

Return Value

bool

at line 194
protected bool shouldFail(Throwable $throwable)

Determine if the job should be failed for the given exception.

Parameters

Throwable $throwable

Return Value

bool

at line 209
ThrottlesExceptions withPrefix(string $prefix)

Set the prefix of the rate limiter key.

Parameters

string $prefix

Return Value

ThrottlesExceptions

at line 221
ThrottlesExceptions store(UnitEnum|string $store)

Specify the rate limiter store that should be used.

Parameters

UnitEnum|string $store

Return Value

ThrottlesExceptions

at line 233
ThrottlesExceptions backoff(Closure|int $backoff)

Specify the number of minutes a job should be delayed when it is released (before it has reached its max exceptions).

Parameters

Closure|int $backoff

Return Value

ThrottlesExceptions

at line 243
protected int getTimeUntilNextRetryAfterException(Throwable $throwable)

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

Parameters

Throwable $throwable

Return Value

int

at line 255
protected string getKey(mixed $job)

Get the key associated with the rate limiter.

Parameters

mixed $job

Return Value

string

at line 275
ThrottlesExceptions by(string $key)

Set the value that the rate limiter should be keyed by.

Parameters

string $key

Return Value

ThrottlesExceptions

at line 285
ThrottlesExceptions byJob()

Indicate that the throttle key should use the job's UUID.

Return Value

ThrottlesExceptions

at line 295
ThrottlesExceptions report(callable|null $callback = null)

Report exceptions and optionally specify a callback that determines if the exception should be reported.

Parameters

callable|null $callback

Return Value

ThrottlesExceptions