Lines
100.00%
14 / 14
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| planReload | 100.00% | 13 / 13 | 100.00% | 1 / 1 | 2 | ||
| 16 | final readonly class ReloadPlanner | |
| 17 | { | |
| 18 | public function __construct( | |
| 19 | private ConfigLoader $configs, | |
| 20 | private AppCatalogResolver $catalogs, | |
| 21 | private AppPlacement $placement, | |
| 22 | private ConfigChangeClassifier $changes, | |
| 23 | private DaemonLaunchOptions $launch, | |
| 24 | private StewartConfig $runningConfig, | |
| 25 | ) {} | |
| 26 | ||
| 27 | /** @throws StewartException */ | |
| 28 | public function planReload(ReloadCheckReport $report): ReloadPlan | |
| 29 | { | |
| 30 | $configFile = $this->launch->configFile; | |
| 31 | ||
| 32 | // The child checked one version of the file; applying another would skip the check. | |
| 33 | if ($this->configs->fingerprintConfigFile($configFile) !== $report->configFingerprint) { | |
| 34 | throw BrokerException::createForReason(BrokerError::ReloadConfigChanged, path: $this->configs->locateConfigFile($configFile)); | |
| 35 | } | |
| 36 | ||
| 37 | $config = $this->configs->loadConfig($configFile, $this->launch->listConfigOverrides()); | |
| 38 | $discovered = $report->restoreDiscovery(); | |
| 39 | $catalog = $this->catalogs->resolveCatalog($discovered, $config->apps, $config->workers, $this->launch->selection); | |
| 40 | ||
| 41 | return new ReloadPlan( | |
| 42 | $discovered, | |
| 43 | $catalog, | |
| 44 | $this->placement->planWorkerSlots($catalog->enabled, $config), | |
| 45 | $this->changes->listSettingsNeedingRestart($this->runningConfig, $config), | |
| 46 | $report->generated, | |
| 47 | ); | |
| 48 | } | |
| 49 | } |