Skip to content

Commit

Permalink
+ custom queued handler
Browse files Browse the repository at this point in the history
  • Loading branch information
dusterio committed Nov 27, 2022
1 parent 09573b1 commit 7a56a37
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/Jobs/CallQueuedHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,23 @@ class CallQueuedHandler extends LaravelHandler {
*/
protected function dispatchThroughMiddleware(Job $job, $command)
{
if ($this->hasExpired($command, $job->timestamp())) {
throw new ExpiredJobException("This job has already expired");
if (property_exists($command, 'class') && $this->hasExpired($command->class, $job->timestamp())) {
throw new ExpiredJobException("Job {$command->class} has already expired");
}

return parent::dispatchThroughMiddleware($job, $command);
}

/**
* @param $command
* @param $className
* @param $queuedAt
* @return bool
*/
protected function hasExpired($command, $queuedAt) {
if (! property_exists($command, 'class')) {
protected function hasExpired($className, $queuedAt) {
if (! property_exists($className, 'retention')) {
return false;
}

if (! property_exists($command->class, 'retention')) {
return false;
}

return time() > $queuedAt + $command->class::$retention;
return time() > $queuedAt + $className::$retention;
}
}

0 comments on commit 7a56a37

Please sign in to comment.