feat: M3 import & indexing engine delivery layer with durable collision handling, space checking and console
This commit is contained in:
1 parent
93d991703c
commit
9d277d9e72
48 files changed
+5147
-4
No files matched your search
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MeshVault\Console;
|
||||
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* Defers engine construction until a command actually needs it, so usage
|
||||
* errors and help never require a configured database or library.
|
||||
*/
|
||||
final class LazyConsoleServices implements ConsoleServices
|
||||
{
|
||||
private readonly Closure $factory;
|
||||
|
||||
private ?ConsoleServices $delegate = null;
|
||||
|
||||
/** @param callable(): ConsoleServices $factory */
|
||||
public function __construct(callable $factory)
|
||||
{
|
||||
$this->factory = Closure::fromCallable($factory);
|
||||
}
|
||||
|
||||
public function import(string $sourcePath, array $extensions): int
|
||||
{
|
||||
return $this->delegate()->import($sourcePath, $extensions);
|
||||
}
|
||||
|
||||
public function runWorkerOnce(callable $shouldStop): ?int
|
||||
{
|
||||
return $this->delegate()->runWorkerOnce($shouldStop);
|
||||
}
|
||||
|
||||
private function delegate(): ConsoleServices
|
||||
{
|
||||
return $this->delegate ??= ($this->factory)();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user