• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 21017989272

15 Jan 2026 02:53AM UTC coverage: 44.43%. First build
21017989272

Pull #6436

github

web-flow
Merge 6ef45535a into db0316516
Pull Request #6436: feat: async parallel signing

415 of 962 new or added lines in 46 files covered. (43.14%)

7036 of 15836 relevant lines covered (44.43%)

4.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

4.76
/lib/Service/WorkerHealthService.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Service;
10

11
use OCA\Libresign\Service\Worker\StartThrottlePolicy;
12
use OCA\Libresign\Service\Worker\WorkerConfiguration;
13
use OCA\Libresign\Service\Worker\WorkerCounter;
14
use OCA\Libresign\Service\Worker\WorkerStarter;
15
use Psr\Log\LoggerInterface;
16

17
class WorkerHealthService {
18
        public function __construct(
19
                private WorkerConfiguration $config,
20
                private WorkerCounter $counter,
21
                private StartThrottlePolicy $throttle,
22
                private WorkerStarter $starter,
23
                private LoggerInterface $logger,
24
        ) {
25
        }
6✔
26

27
        public function isAsyncLocalEnabled(): bool {
NEW
28
                return $this->config->isAsyncLocalEnabled();
×
29
        }
30

31
        public function ensureWorkerRunning(): bool {
32
                try {
NEW
33
                        if (!$this->config->isAsyncLocalEnabled()) {
×
NEW
34
                                return false;
×
35
                        }
36

NEW
37
                        $workersNeeded = $this->calculateWorkersNeeded();
×
NEW
38
                        if ($workersNeeded === 0) {
×
NEW
39
                                return true;
×
40
                        }
41

NEW
42
                        if ($this->throttle->isThrottled()) {
×
NEW
43
                                return true;
×
44
                        }
45

NEW
46
                        $this->throttle->recordAttempt();
×
NEW
47
                        $this->starter->startWorkers($workersNeeded);
×
NEW
48
                        return true;
×
NEW
49
                } catch (\Throwable $e) {
×
NEW
50
                        $this->logger->error('Failed to ensure worker is running: {error}', [
×
NEW
51
                                'error' => $e->getMessage(),
×
NEW
52
                                'exception' => $e,
×
NEW
53
                        ]);
×
NEW
54
                        return false;
×
55
                }
56
        }
57

58
        private function calculateWorkersNeeded(): int {
NEW
59
                $desired = $this->config->getDesiredWorkerCount();
×
NEW
60
                $running = $this->counter->countRunning();
×
NEW
61
                return max(0, $desired - $running);
×
62
        }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc