Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/Illuminate/Queue/BeanstalkdQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public function size($queue = null)
*/
public function push($job, $data = '', $queue = null)
{
return $this->pushRaw($this->createPayload($job, $this->getQueue($queue), $data), $queue);
return $this->enqueueUsing($job, function () use ($data, $queue, $job) {
return $this->pushRaw($this->createPayload($job, $this->getQueue($queue), $data), $queue);
});
}

/**
Expand Down Expand Up @@ -108,12 +110,14 @@ public function later($delay, $job, $data = '', $queue = null)
{
$pheanstalk = $this->pheanstalk->useTube($this->getQueue($queue));

return $pheanstalk->put(
$this->createPayload($job, $this->getQueue($queue), $data),
Pheanstalk::DEFAULT_PRIORITY,
$this->secondsUntil($delay),
$this->timeToRun
);
return $this->enqueueUsing($job, function () use ($delay, $pheanstalk, $data, $queue, $job) {
return $pheanstalk->put(
$this->createPayload($job, $this->getQueue($queue), $data),
Pheanstalk::DEFAULT_PRIORITY,
$this->secondsUntil($delay),
$this->timeToRun
);
});
}

/**
Expand Down
16 changes: 10 additions & 6 deletions src/Illuminate/Queue/DatabaseQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ public function size($queue = null)
*/
public function push($job, $data = '', $queue = null)
{
return $this->pushToDatabase($queue, $this->createPayload(
$job, $this->getQueue($queue), $data
));
return $this->enqueueUsing($job, function () use ($data, $queue, $job) {
return $this->pushToDatabase($queue, $this->createPayload(
$job, $this->getQueue($queue), $data
));
});
}

/**
Expand All @@ -109,9 +111,11 @@ public function pushRaw($payload, $queue = null, array $options = [])
*/
public function later($delay, $job, $data = '', $queue = null)
{
return $this->pushToDatabase($queue, $this->createPayload(
$job, $this->getQueue($queue), $data
), $delay);
return $this->enqueueUsing($job, function () use ($delay, $data, $queue, $job) {
return $this->pushToDatabase($queue, $this->createPayload(
$job, $this->getQueue($queue), $data
), $delay);
});
}

/**
Expand Down
12 changes: 12 additions & 0 deletions src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ protected function withCreatePayloadHooks($queue, array $payload)
return $payload;
}

/**
* Enqueue a job using the given callback.
*
* @param callable $callback
* @param \Closure|string|object $job
* @return mixed
*/
protected function enqueueUsing($job, $callback)
{
return call_user_func($callback);
}

/**
* Get the connection name for the queue.
*
Expand Down
8 changes: 6 additions & 2 deletions src/Illuminate/Queue/RedisQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ public function bulk($jobs, $data = '', $queue = null)
*/
public function push($job, $data = '', $queue = null)
{
return $this->pushRaw($this->createPayload($job, $this->getQueue($queue), $data), $queue);
return $this->enqueueUsing($job, function () use ($data, $queue, $job) {
return $this->pushRaw($this->createPayload($job, $this->getQueue($queue), $data), $queue);
});
}

/**
Expand Down Expand Up @@ -140,7 +142,9 @@ public function pushRaw($payload, $queue = null, array $options = [])
*/
public function later($delay, $job, $data = '', $queue = null)
{
return $this->laterRaw($delay, $this->createPayload($job, $this->getQueue($queue), $data), $queue);
return $this->enqueueUsing($job, function () use ($delay, $data, $queue, $job) {
return $this->laterRaw($delay, $this->createPayload($job, $this->getQueue($queue), $data), $queue);
});
}

/**
Expand Down
16 changes: 10 additions & 6 deletions src/Illuminate/Queue/SqsQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public function size($queue = null)
*/
public function push($job, $data = '', $queue = null)
{
return $this->pushRaw($this->createPayload($job, $queue ?: $this->default, $data), $queue);
return $this->enqueueUsing($job, function () use ($data, $queue, $job) {
return $this->pushRaw($this->createPayload($job, $queue ?: $this->default, $data), $queue);
});
}

/**
Expand Down Expand Up @@ -112,11 +114,13 @@ public function pushRaw($payload, $queue = null, array $options = [])
*/
public function later($delay, $job, $data = '', $queue = null)
{
return $this->sqs->sendMessage([
'QueueUrl' => $this->getQueue($queue),
'MessageBody' => $this->createPayload($job, $queue ?: $this->default, $data),
'DelaySeconds' => $this->secondsUntil($delay),
])->get('MessageId');
return $this->enqueueUsing($job, function () use ($delay, $data, $queue, $job) {
return $this->sqs->sendMessage([
'QueueUrl' => $this->getQueue($queue),
'MessageBody' => $this->createPayload($job, $queue ?: $this->default, $data),
'DelaySeconds' => $this->secondsUntil($delay),
])->get('MessageId');
});
}

/**
Expand Down