Skip to content

Commit

Permalink
Queue worker will pass connection + queue name to Looping event
Browse files Browse the repository at this point in the history
  • Loading branch information
stierler committed Apr 28, 2017
1 parent 9e575de commit 3f01a66
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
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

0 comments on commit 3f01a66

Please sign in to comment.