diff --git a/src/WorkerPool.php b/src/WorkerPool.php index 624e936..9fe9d9a 100644 --- a/src/WorkerPool.php +++ b/src/WorkerPool.php @@ -34,7 +34,17 @@ public function addWorker(string $plugin): void */ public function countWorkers(string $plugin): int { - return (int)($this->rpc->call('informer.Workers', $plugin)['workers'] ?? 0); + return count($this->getWorkers($plugin)); + } + + /** + * Get the info about running workers for a pool. + * + * @param non-empty-string $plugin + */ + public function getWorkers(string $plugin): array + { + return $this->rpc->call('informer.Workers', $plugin)['workers']; } /** diff --git a/tests/Unit/WorkerPoolTest.php b/tests/Unit/WorkerPoolTest.php index 225d18f..86a49c3 100644 --- a/tests/Unit/WorkerPoolTest.php +++ b/tests/Unit/WorkerPoolTest.php @@ -37,11 +37,18 @@ public function testAddWorker(): void public function testCountWorkers(): void { - $this->rpc->expects($this->once())->method('call')->with('informer.Workers', 'test'); + $this->rpc->expects($this->once())->method('call')->with('informer.Workers', 'test')->willReturn(['workers' => []]); $this->workerPool->countWorkers('test'); } + public function testGetWorkers(): void + { + $this->rpc->expects($this->once())->method('call')->with('informer.Workers', 'test')->willReturn(['workers' => []]); + + $this->workerPool->getWorkers('test'); + } + public function testRemoveWorker(): void { $this->rpc->expects($this->once())->method('call')->with('informer.RemoveWorker', 'test');