Skip to content

Commit

Permalink
adjust behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 9, 2021
1 parent 2584678 commit b8a70e9
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/Illuminate/Queue/Middleware/ThrottlesExceptions.php
Expand Up @@ -15,6 +15,13 @@ class ThrottlesExceptions
*/
protected $key;

/**
* Indicates whether the throttle key should use the job's UUID.
*
* @var bool
*/
protected $byJob = false;

/**
* The maximum number of attempts allowed before rate limiting applies.
*
Expand Down Expand Up @@ -148,7 +155,13 @@ public function backoff($backoff)
*/
protected function getKey($job)
{
return $this->key ? $this->prefix.$this->key : $this->prefix.$job->job->uuid();
if ($this->key) {
return $this->prefix.$this->key;
} elseif ($this->byJob) {
return $this->prefix.$job->job->uuid();
}

return $this->prefix.md5(get_class($job));
}

/**
Expand All @@ -164,6 +177,18 @@ public function by($key)
return $this;
}

/**
* Indicate that the throttle key should use the job's UUID.
*
* @return $this
*/
public function byJob()
{
$this->byJob = true;

return $this;
}

/**
* Get the number of seconds that should elapse before the job is retried.
*
Expand Down

0 comments on commit b8a70e9

Please sign in to comment.