diff --git a/src/Ingest/IngestFlow.php b/src/Ingest/IngestFlow.php index 94b846a..25d76e7 100644 --- a/src/Ingest/IngestFlow.php +++ b/src/Ingest/IngestFlow.php @@ -240,8 +240,6 @@ final readonly class IngestFlow */ private function withLock(callable $fn): void { - $this->lockService->acquire(); - try { $fn(); } finally { diff --git a/src/Service/IngestOrchestrator.php b/src/Service/IngestOrchestrator.php index aba9a3b..e4a914d 100644 --- a/src/Service/IngestOrchestrator.php +++ b/src/Service/IngestOrchestrator.php @@ -12,18 +12,20 @@ use Symfony\Component\Uid\Uuid; final class IngestOrchestrator { public function __construct( - private readonly LockService $lockService, - private readonly IngestJobService $jobService, + private readonly LockService $lockService, + private readonly IngestJobService $jobService, private readonly EntityManagerInterface $em, - private readonly IngestFlow $ingestFlow, - ) { + private readonly IngestFlow $ingestFlow, + ) + { } public function runForVersion( DocumentVersion $version, - User $user, - bool $dryRun = false - ): IngestJob { + User $user, + bool $dryRun = false + ): IngestJob + { if (!$this->lockService->acquire()) { throw new \RuntimeException('Another ingest job is already running.'); @@ -172,41 +174,4 @@ final class IngestOrchestrator } } - public function runGlobal(User $user, bool $dryRun = false): IngestJob - { - if (!$this->lockService->acquire()) { - throw new \RuntimeException('Another ingest job is already running.'); - } - - $job = null; - - try { - - $job = $this->jobService->startJob( - IngestJob::TYPE_GLOBAL_REINDEX, - $user - ); - - if ($dryRun) { - usleep(200000); - } else { - $this->ingestFlow->globalReindex(); - } - - $this->jobService->markCompleted($job); - - return $job; - - } catch (\Throwable $e) { - - if ($job) { - $this->jobService->markFailed($job, $e->getMessage()); - } - - throw $e; - - } finally { - $this->lockService->release(); - } - } }