Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Queue worker will pass connection + queue name to Looping event #19081

Merged
merged 1 commit into from
May 8, 2017
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
27 changes: 26 additions & 1 deletion src/Illuminate/Queue/Events/Looping.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,30 @@

class Looping
{
//
/**
* The connection name.
*
* @var string
*/
public $connectionName;

/**
* The queue name.
*
* @var string
*/
public $queue;

/**
* Create a new event instance.
*
* @param string $connectionName
* @param string $queue
* @return void
*/
public function __construct($connectionName, $queue)
{
$this->connectionName = $connectionName;
$this->queue = $queue;
}
}
8 changes: 5 additions & 3 deletions src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function daemon($connectionName, $queue, WorkerOptions $options)
// Before reserving any jobs, we will make sure this queue is not paused and
// if it is we will just pause this worker for a given amount of time and
// make sure we do not need to kill this worker process off completely.
if (! $this->daemonShouldRun($options)) {
if (! $this->daemonShouldRun($options, $connectionName, $queue)) {
$this->pauseWorker($options, $lastRestart);

continue;
Expand Down Expand Up @@ -156,13 +156,15 @@ protected function timeoutForJob($job, WorkerOptions $options)
* Determine if the daemon should process on this iteration.
*
* @param WorkerOptions $options
* @param string $connectionName
* @param string $queue
* @return bool
*/
protected function daemonShouldRun(WorkerOptions $options)
protected function daemonShouldRun(WorkerOptions $options, $connectionName, $queue)
{
return ! (($this->manager->isDownForMaintenance() && ! $options->force) ||
$this->paused ||
$this->events->until(new Events\Looping) === false);
$this->events->until(new Events\Looping($connectionName, $queue)) === false);
}

/**
Expand Down