Skip to content

Commit

Permalink
Merge pull request #32 from spiral/hotfix/pipeline-stat
Browse files Browse the repository at this point in the history
Fixes jobs pipeline stat for console command
  • Loading branch information
butschster authored Sep 28, 2022
2 parents 02a6549 + b1fbe22 commit c461f46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
8 changes: 3 additions & 5 deletions src/Console/Command/Queue/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,22 @@ public function perform(JobsInterface $jobs): int
$table = new Table($this->output);

$table->setHeaders(
['Name', 'Driver', 'Default delay', 'Priority', 'Active jobs', 'Delayed jobs', 'Reserved jobs', 'Is active']
['Name', 'Driver', 'Priority', 'Active jobs', 'Delayed jobs', 'Reserved jobs', 'Is active']
);

foreach ($queues as $queue) {
/** @var Queue $queue */

$options = $queue->getDefaultOptions();
$stat = $queue->getPipelineStat();

$table->addRow([
$stat->getPipeline(),
$stat->getDriver(),
$options->getDelay(),
$options->getPriority(),
$stat->getPriority(),
$stat->getActive(),
$stat->getDelayed(),
$stat->getReserved(),
$queue->isPaused() ? '<fg=red> ✖ </>' : '<fg=green> ✓ </>',
$stat->getReady() ? '<fg=red> ✖ </>' : '<fg=green> ✓ </>',
]);
}

Expand Down
22 changes: 10 additions & 12 deletions tests/src/Console/Command/Queue/ListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,40 @@ public function testGetsListOfAvailablePipelines()
])
);

$memory->shouldReceive('getDefaultOptions')->once()->andReturn(new Options(55, 200));
$memory->shouldReceive('getPipelineStat')->once()->andReturn(
new Stat([
'pipeline' => 'test',
'driver' => 'memory',
'queue' => 'local',
'ready' => true,
'active' => 100,
'delayed' => 5,
'delayed' => 55,
'priority' => 200,
'reserved' => 8,
])
);
$memory->shouldReceive('isPaused')->once()->andReturnFalse();

$amqp->shouldReceive('getDefaultOptions')->once()->andReturn(new Options(88, 250));
$amqp->shouldReceive('getPipelineStat')->once()->andReturn(
new Stat([
'pipeline' => 'default',
'driver' => 'amqp',
'queue' => 'local',
'ready' => true,
'active' => 110,
'delayed' => 17,
'delayed' => 88,
'priority' => 250,
'reserved' => 56,
])
);
$amqp->shouldReceive('isPaused')->once()->andReturnTrue();

$this->assertStringContainsString(
<<<EOL
+---------+--------+---------------+----------+-------------+--------------+---------------+-----------+
| Name | Driver | Default delay | Priority | Active jobs | Delayed jobs | Reserved jobs | Is active |
+---------+--------+---------------+----------+-------------+--------------+---------------+-----------+
| test | memory | 55 | 200 | 100 | 5 | 8 | |
| default | amqp | 88 | 250 | 110 | 17 | 56 | ✖ |
+---------+--------+---------------+----------+-------------+--------------+---------------+-----------+
+---------+--------+----------+-------------+--------------+---------------+-----------+
| Name | Driver | Priority | Active jobs | Delayed jobs | Reserved jobs | Is active |
+---------+--------+----------+-------------+--------------+---------------+-----------+
| test | memory | 200 | 100 | 55 | 8 | |
| default | amqp | 250 | 110 | 88 | 56 | ✖ |
+---------+--------+----------+-------------+--------------+---------------+-----------+
EOL,
$this->runCommand('roadrunner:list')
);
Expand Down

0 comments on commit c461f46

Please sign in to comment.