Skip to content

Commit d83c731

Browse files
committed
[internal-api-client] OrchestrationJobMatcher::matchTaskJobsForOrchestrationJob with optional ComponentsApi
1 parent 4e66cc5 commit d83c731

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/Orchestration/OrchestrationJobMatcher.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ class OrchestrationJobMatcher
1616
{
1717
public function __construct(
1818
private readonly Client $internalClient,
19-
private readonly ?Components $componentsApi = null,
2019
) {
2120
}
2221

23-
public function matchTaskJobsForOrchestrationJob(string $jobId): OrchestrationJobMatcherResults
24-
{
22+
public function matchTaskJobsForOrchestrationJob(
23+
string $jobId,
24+
?Components $componentsApi = null,
25+
): OrchestrationJobMatcherResults {
2526
$job = $this->internalClient->getJob($jobId);
2627

2728
$childJobs = $this->getOrchestrationTaskJobs($job);
28-
$configuration = $this->getCurrentOrchestrationConfiguration($job);
29+
$configuration = $this->getCurrentOrchestrationConfiguration($job, $componentsApi);
2930
$this->validateInputs($job, $configuration);
3031
$matchedTasks = [];
3132
foreach ($configuration['tasks'] as $task) {
@@ -67,18 +68,18 @@ private function getOrchestrationTaskJobs(JobInterface $job): array
6768
);
6869
}
6970

70-
private function getCurrentOrchestrationConfiguration(JobInterface $job): array
71+
private function getCurrentOrchestrationConfiguration(JobInterface $job, ?Components $componentsApi = null): array
7172
{
7273
$configuration = $job->getConfigData();
7374
if ($configuration) {
7475
return $configuration;
7576
}
7677

7778
// for situations where job token is expired/deleted
78-
if ($this->componentsApi) {
79+
if ($componentsApi) {
7980
return JobFactory\JobConfigurationResolver::resolveJobConfiguration(
8081
$job,
81-
$this->componentsApi,
82+
$componentsApi,
8283
)['configuration'];
8384
}
8485

tests/Orchestration/OrchestrationJobMatcherTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,9 @@ public function testMatcherLoadsConfigurationDirectlyFromComponentsApi(): void
380380
])
381381
;
382382

383-
$matcher = new OrchestrationJobMatcher($queueClientMock, $componentsApiMock);
383+
$matcher = new OrchestrationJobMatcher($queueClientMock);
384384

385-
$results = $matcher->matchTaskJobsForOrchestrationJob('123');
385+
$results = $matcher->matchTaskJobsForOrchestrationJob('123', $componentsApiMock);
386386

387387
self::assertSame('123', $results->jobId);
388388
self::assertSame('456', $results->configId);

0 commit comments

Comments
 (0)