Skip to content

Commit

Permalink
Info about workers was removed as unnecessary for redis driver
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuravljov committed Feb 19, 2018
1 parent 38b1d46 commit a97007c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
28 changes: 0 additions & 28 deletions src/drivers/redis/InfoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,5 @@ public function run()

Console::stdout($this->format('- done: ', Console::FG_YELLOW));
Console::output($done);

if ($workersInfo = $this->getWorkersInfo()) {
Console::output($this->format('Workers ', Console::FG_GREEN));
foreach ($workersInfo as $name => $info) {
Console::stdout($this->format("- $name: ", Console::FG_YELLOW));
Console::output($info['addr']);
}
}
}
/**
* @return array
*/
protected function getWorkersInfo()
{
$workers = [];
$data = $this->queue->redis->clientList();
foreach (explode("\n", trim($data)) as $line) {
$client = [];
foreach (explode(' ', trim($line)) as $pair) {
list($key, $value) = explode('=', $pair, 2);
$client[$key] = $value;
}
if (isset($client['name']) && strpos($client['name'], $this->queue->channel . '.worker') === 0) {
$workers[$client['name']] = $client;
}
}

return $workers;
}
}
13 changes: 0 additions & 13 deletions src/drivers/redis/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function init()
public function run($repeat, $timeout = 0)
{
return $this->runWorker(function (callable $canContinue) use ($repeat, $timeout) {
$this->openWorker();
while ($canContinue()) {
if (($payload = $this->reserve($timeout)) !== null) {
list($id, $message, $ttr, $attempt) = $payload;
Expand All @@ -66,7 +65,6 @@ public function run($repeat, $timeout = 0)
break;
}
}
$this->closeWorker();
});
}

Expand Down Expand Up @@ -203,15 +201,4 @@ protected function pushMessage($message, $ttr, $delay, $priority)

return $id;
}

protected function openWorker()
{
$id = $this->redis->incr("$this->channel.worker_id");
$this->redis->clientSetname("$this->channel.worker.$id");
}

protected function closeWorker()
{
$this->redis->clientSetname('');
}
}

0 comments on commit a97007c

Please sign in to comment.