ThrottlesExceptionsWithRedis
class ThrottlesExceptionsWithRedis extends ThrottlesExceptions
Traits
Properties
| protected string|null | $key | The developer specified key that the rate limiter should use. |
from ThrottlesExceptions |
| protected bool | $byJob | Indicates whether the throttle key should use the job's UUID. |
from ThrottlesExceptions |
| protected Closure|int | $retryAfterMinutes | The number of minutes to wait before retrying the job after an exception. |
from ThrottlesExceptions |
| protected ?callable | $reportCallback | The callback that determines if the exception should be reported. |
from ThrottlesExceptions |
| protected ?callable | $whenCallback | The callback that determines if rate limiting should apply. |
from ThrottlesExceptions |
| protected callable[] | $deleteWhenCallbacks | The callbacks that determine if the job should be deleted. |
from ThrottlesExceptions |
| protected callable[] | $failWhenCallbacks | The callbacks that determine if the job should be failed. |
from ThrottlesExceptions |
| protected string | $prefix | The prefix of the rate limiter key. |
from ThrottlesExceptions |
| protected | $limiter | The rate limiter instance. |
from ThrottlesExceptions |
| protected RedisProxy|null | $redis | The Redis connection instance. |
|
| protected string|null | $connectionName | The Redis connection that should be used. |
Methods
Create a new middleware instance.
Process the job.
Specify a callback that should determine if rate limiting behavior should apply.
Add a callback that should determine if the job should be deleted.
Add a callback that should determine if the job should be failed.
Set the prefix of the rate limiter key.
Specify the number of minutes a job should be delayed when it is released (before it has reached its max exceptions).
Get the number of seconds that should elapse before the job is retried after an exception.
Get the cache key associated for the rate limiter.
Set the value that the rate limiter should be keyed by.
Indicate that the throttle key should use the job's UUID.
Report exceptions and optionally specify a callback that determines if the exception should be reported.
Get the number of seconds that should elapse before the job is retried.
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Specify the Redis connection that should be used.
Details
in
ThrottlesExceptions at line 75
__construct(int $maxAttempts = 10, int $decaySeconds = 600)
Create a new middleware instance.
at line 31
mixed
handle(mixed $job, callable $next)
Process the job.
in
ThrottlesExceptions at line 125
ThrottlesExceptions
when(callable $callback)
Specify a callback that should determine if rate limiting behavior should apply.
in
ThrottlesExceptions at line 135
ThrottlesExceptions
deleteWhen(callable|string $callback)
Add a callback that should determine if the job should be deleted.
in
ThrottlesExceptions at line 147
ThrottlesExceptions
failWhen(callable|string $callback)
Add a callback that should determine if the job should be failed.
in
ThrottlesExceptions at line 159
protected bool
shouldDelete(Throwable $throwable)
Determine if the job should be deleted for the given exception.
in
ThrottlesExceptions at line 173
protected bool
shouldFail(Throwable $throwable)
Determine if the job should be failed for the given exception.
in
ThrottlesExceptions at line 187
ThrottlesExceptions
withPrefix(string $prefix)
Set the prefix of the rate limiter key.
in
ThrottlesExceptions at line 197
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).
in
ThrottlesExceptions at line 207
protected int
getTimeUntilNextRetryAfterException(Throwable $throwable)
Get the number of seconds that should elapse before the job is retried after an exception.
in
ThrottlesExceptions at line 219
protected string
getKey(mixed $job)
Get the cache key associated for the rate limiter.
in
ThrottlesExceptions at line 239
ThrottlesExceptions
by(string $key)
Set the value that the rate limiter should be keyed by.
in
ThrottlesExceptions at line 249
ThrottlesExceptions
byJob()
Indicate that the throttle key should use the job's UUID.
in
ThrottlesExceptions at line 259
ThrottlesExceptions
report(callable|null $callback = null)
Report exceptions and optionally specify a callback that determines if the exception should be reported.
in
ThrottlesExceptions at line 269
protected int
getTimeUntilNextRetry(string $key)
Get the number of seconds that should elapse before the job is retried.
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 41
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 57
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 65
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
at line 80
ThrottlesExceptionsWithRedis
connection(string $name)
Specify the Redis connection that should be used.