Skip to content

Commit 8252323

Browse files
committed
refactor(worker): calculate workers from process manager
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent b06ab3a commit 8252323

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/Service/Worker/WorkerHealthService.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88

99
namespace OCA\Libresign\Service\Worker;
1010

11+
use OCA\Libresign\Service\Process\ProcessManager;
1112
use Psr\Log\LoggerInterface;
1213

1314
class WorkerHealthService {
15+
private const PROCESS_SOURCE = 'worker';
16+
1417
public function __construct(
1518
private WorkerConfiguration $workerConfiguration,
16-
private WorkerCounter $workerCounter,
19+
private ProcessManager $processManager,
1720
private WorkerJobCounter $workerJobCounter,
1821
private StartThrottlePolicy $startThrottlePolicy,
1922
private WorkerStarter $workerStarter,
@@ -54,7 +57,7 @@ public function ensureWorkerRunning(): bool {
5457

5558
private function calculateWorkersNeeded(): int {
5659
$desired = $this->workerConfiguration->getDesiredWorkerCount();
57-
$running = $this->workerCounter->countRunning();
60+
$running = $this->processManager->countRunning(self::PROCESS_SOURCE);
5861
$pendingJobs = $this->workerJobCounter->countPendingJobs();
5962

6063
if ($this->hasNoPendingWork($pendingJobs)) {

0 commit comments

Comments
 (0)