Skip to content

Commit

Permalink
use enqueueUsing when pushing delayed jobs (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Dec 1, 2020
1 parent 4e21779 commit f69fd50
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/RedisQueue.php
Expand Up @@ -95,6 +95,20 @@ public function later($delay, $job, $data = '', $queue = null)
{
$payload = (new JobPayload($this->createPayload($job, $queue, $data)))->prepare($job)->value;

if (method_exists($this, 'enqueueUsing')) {
return $this->enqueueUsing(
$job,
$payload,
$queue,
$delay,
function ($payload, $queue, $delay) {
return tap(parent::laterRaw($delay, $payload, $queue), function () use ($payload, $queue) {
$this->event($this->getQueue($queue), new JobPushed($payload));
});
}
);
}

return tap(parent::laterRaw($delay, $payload, $queue), function () use ($payload, $queue) {
$this->event($this->getQueue($queue), new JobPushed($payload));
});
Expand Down

0 comments on commit f69fd50

Please sign in to comment.