Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/CommonJob.php
Show All 24 Lines | abstract class CommonJob implements ShouldQueue | ||||
/** | /** | ||||
* The failure message. | * The failure message. | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
public $failureMessage; | public $failureMessage; | ||||
/** | /** | ||||
* The job released state. | |||||
* | |||||
* @var bool | |||||
*/ | |||||
protected $isReleased = false; | |||||
/** | |||||
* The number of tries for this Job. | * The number of tries for this Job. | ||||
* | * | ||||
* @var int | * @var int | ||||
*/ | */ | ||||
public $tries = 5; | public $tries = 5; | ||||
/** | /** | ||||
* Execute the job. | * Execute the job. | ||||
Show All 24 Lines | abstract class CommonJob implements ShouldQueue | ||||
* Check if the job has failed | * Check if the job has failed | ||||
* | * | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public function hasFailed(): bool | public function hasFailed(): bool | ||||
{ | { | ||||
return $this->failureMessage !== null; | return $this->failureMessage !== null; | ||||
} | } | ||||
/** | |||||
* Release the job back into the queue. | |||||
* | |||||
* @param int $delay Time in seconds | |||||
* @return void | |||||
*/ | |||||
public function release($delay = 0) | |||||
{ | |||||
// We need this for testing purposes | |||||
$this->isReleased = true; | |||||
// @phpstan-ignore-next-line | |||||
if ($this->job) { | |||||
$this->job->release($delay); | |||||
} | |||||
} | |||||
/** | |||||
* Check if the job was released | |||||
* | |||||
* @return bool | |||||
*/ | |||||
public function isReleased(): bool | |||||
{ | |||||
return $this->isReleased; | |||||
} | |||||
} | } |