ThrottlesExceptions
class ThrottlesExceptions (View source)
Properties
protected string | $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 int | $maxAttempts | The maximum number of attempts allowed before rate limiting applies. |
|
protected int | $decaySeconds | The number of seconds until the maximum attempts are reset. |
|
protected 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 string | $prefix | The prefix of the rate limiter key. |
|
protected RateLimiter | $limiter | The rate limiter instance. |
Methods
Create a new middleware instance.
Process the job.
Specify a callback that should determine if rate limiting behavior should apply.
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 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.
Details
void
__construct(int $maxAttempts = 10, int $decaySeconds = 600)
Create a new middleware instance.
mixed
handle(mixed $job, callable $next)
Process the job.
$this
when(callable $callback)
Specify a callback that should determine if rate limiting behavior should apply.
$this
withPrefix(string $prefix)
Set the prefix of the rate limiter key.
$this
backoff(int $backoff)
Specify the number of minutes a job should be delayed when it is released (before it has reached its max exceptions).
protected string
getKey(mixed $job)
Get the cache key associated for the rate limiter.
$this
by(string $key)
Set the value that the rate limiter should be keyed by.
$this
byJob()
Indicate that the throttle key should use the job's UUID.
$this
report(callable|null $callback = null)
Report exceptions and optionally specify a callback that determines if the exception should be reported.
protected int
getTimeUntilNextRetry(string $key)
Get the number of seconds that should elapse before the job is retried.