Lines
0.00%
0 / 2
Functions and Methods
0.00%
0 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ProcessWorkerSpawner | 0.00% | 0 / 2 | 0.00% | 0 / 2 | 6 | 0.00% | 0 / 1 | |||
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| spawn | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Broker; | |
| 6 | ||
| 7 | use Amp\Cancellation; | |
| 8 | use Amp\Parallel\Context\ProcessContextFactory; | |
| 9 | use Stewart\Runtime\Ipc\Wire\IpcCodec; | |
| 10 | use Stewart\Runtime\Model\WorkerId; | |
| 11 | ||
| 12 | final readonly class ProcessWorkerSpawner implements WorkerSpawner | |
| 13 | { | |
| 14 | private const string ENTRYPOINT = __DIR__ . '/../../bin/worker.php'; | |
| 15 | ||
| 16 | public function __construct( | |
| 17 | private ProcessContextFactory $contexts, | |
| 18 | private IpcCodec $ipcCodec, | |
| 19 | ) {} | |
| 20 | ||
| 21 | public function spawn(WorkerId $workerId, Cancellation $deadline): WorkerProcess | |
| 22 | { | |
| 23 | return new ProcessContextWorker($this->contexts->start([self::ENTRYPOINT, (string) $workerId], $deadline), $this->ipcCodec); | |
| 24 | } | |
| 25 | } |