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
@@ -3,12 +3,86 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use MeshVault\Config\AppConfig;
|
||||
use MeshVault\Console\ConsoleServices;
|
||||
use MeshVault\Console\ContainerConsoleServices;
|
||||
use MeshVault\Console\ImportWorkerFactory;
|
||||
use MeshVault\Http\View;
|
||||
use MeshVault\Indexer\Contracts\FileEnumeratorInterface;
|
||||
use MeshVault\Indexer\FileEnumerator;
|
||||
use MeshVault\Indexer\Filesystem\LocalFilesystem;
|
||||
use MeshVault\Indexer\Filesystem\PathSafety;
|
||||
use MeshVault\Indexer\ImportService;
|
||||
use MeshVault\Indexer\ImportWorker;
|
||||
use MeshVault\Indexer\SpaceChecker;
|
||||
use MeshVault\Indexer\StlValidator;
|
||||
use MeshVault\Indexer\StreamingHasher;
|
||||
use MeshVault\Indexer\VerifiedCopier;
|
||||
use MeshVault\Logging\LoggerFactory;
|
||||
use MeshVault\Repository\CatalogRepositoryInterface;
|
||||
use MeshVault\Repository\ImportJobRepositoryInterface;
|
||||
use MeshVault\Repository\PdoCatalogRepository;
|
||||
use MeshVault\Repository\PdoImportJobRepository;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
return static fn (AppConfig $config): array => [
|
||||
AppConfig::class => $config,
|
||||
View::class => new View(dirname(__DIR__) . '/templates'),
|
||||
LoggerInterface::class => static fn (): LoggerInterface => LoggerFactory::create($config),
|
||||
PDO::class => static fn (): PDO => new PDO(
|
||||
sprintf('pgsql:host=%s;port=%d;dbname=%s', $config->dbHost, $config->dbPort, $config->dbName),
|
||||
$config->dbUser,
|
||||
$config->dbPassword,
|
||||
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false],
|
||||
),
|
||||
PathSafety::class => static fn (): PathSafety => new PathSafety($config->libraryPath),
|
||||
FileEnumeratorInterface::class => static fn (ContainerInterface $c): FileEnumeratorInterface
|
||||
=> new FileEnumerator(new LocalFilesystem(), $c->get(PathSafety::class)),
|
||||
SpaceChecker::class => static fn (): SpaceChecker => new SpaceChecker(),
|
||||
StreamingHasher::class => static fn (ContainerInterface $c): StreamingHasher
|
||||
=> new StreamingHasher($c->get(PathSafety::class)),
|
||||
StlValidator::class => static fn (ContainerInterface $c): StlValidator
|
||||
=> new StlValidator($c->get(PathSafety::class)),
|
||||
VerifiedCopier::class => static fn (ContainerInterface $c): VerifiedCopier
|
||||
=> new VerifiedCopier($c->get(PathSafety::class)),
|
||||
// Repositories share one PDO connection so the job repository's atomic() is a real transaction.
|
||||
CatalogRepositoryInterface::class => static fn (ContainerInterface $c): CatalogRepositoryInterface
|
||||
=> new PdoCatalogRepository($c->get(PDO::class)),
|
||||
ImportJobRepositoryInterface::class => static fn (ContainerInterface $c): ImportJobRepositoryInterface
|
||||
=> new PdoImportJobRepository($c->get(PDO::class)),
|
||||
ImportService::class => static fn (ContainerInterface $c): ImportService => new ImportService(
|
||||
$c->get(FileEnumeratorInterface::class),
|
||||
$c->get(ImportJobRepositoryInterface::class),
|
||||
$c->get(CatalogRepositoryInterface::class),
|
||||
$c->get(SpaceChecker::class),
|
||||
$config->libraryPath,
|
||||
),
|
||||
ImportWorkerFactory::class => static fn (ContainerInterface $c): ImportWorkerFactory
|
||||
=> new class ($c) implements ImportWorkerFactory {
|
||||
public function __construct(private readonly ContainerInterface $c)
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(callable $shouldStop): ImportWorker
|
||||
{
|
||||
/** @var PathSafety $safety */
|
||||
$safety = $c->get(PathSafety::class);
|
||||
return new ImportWorker(
|
||||
$c->get(ImportJobRepositoryInterface::class),
|
||||
$c->get(CatalogRepositoryInterface::class),
|
||||
$c->get(StreamingHasher::class),
|
||||
$c->get(VerifiedCopier::class),
|
||||
$c->get(StlValidator::class),
|
||||
$safety,
|
||||
$c->get(SpaceChecker::class),
|
||||
$safety->libraryRoot(),
|
||||
$c->get(LoggerInterface::class),
|
||||
$shouldStop,
|
||||
);
|
||||
}
|
||||
},
|
||||
ConsoleServices::class => static fn (ContainerInterface $c): ConsoleServices => new ContainerConsoleServices(
|
||||
$c->get(ImportService::class),
|
||||
$c->get(ImportWorkerFactory::class),
|
||||
),
|
||||
];
|
||||
Reference in new issue
Block a user