refactor(logging, queue): replace RedisQueue with FileQueue for async logging

- Update `LoggerInitializer` to use `FileQueue` instead of `RedisQueue` for async logging, improving local file-based queuing.
- Remove unused `RedisQueue` and related Redis configurations.
- Modify `createQueue` to accept `PathProvider` for file path resolution.
- Revise `AGENTS.md` to add detailed AI agent usage and updated guidelines.
- Refactor `ComponentRegistryInitializer` to use explicit dependency injection for `__invoke` method, ensuring cleaner and more maintainable initialization logic.
This commit is contained in:
2025-11-03 20:09:32 +01:00
parent f8fb9b5a45
commit 8919da8a5c
3 changed files with 438 additions and 49 deletions

View File

@@ -17,19 +17,19 @@ final readonly class ComponentRegistryInitializer
{
public function __construct(
private Container $container,
private DiscoveryRegistry $discoveryRegistry
private DiscoveryRegistry $discoveryRegistry,
) {
}
#[Initializer]
public function __invoke(): ComponentRegistryInterface
public function __invoke(
LiveComponentRenderer $renderer,
ComponentCacheManager $cacheManager,
LiveComponentHandler $handler,
ComponentMetaDataCache $metadataCache,
NestedPerformanceTracker $performanceTracker
): ComponentRegistryInterface
{
$renderer = $this->container->get(LiveComponentRenderer::class);
$cacheManager = $this->container->get(ComponentCacheManager::class);
$handler = $this->container->get(LiveComponentHandler::class);
$metadataCache = $this->container->get(ComponentMetadataCache::class);
$performanceTracker = $this->container->get(NestedPerformanceTracker::class);
// DebugPanel is optional
$debugPanel = null;
@@ -39,7 +39,7 @@ final readonly class ComponentRegistryInitializer
// DebugPanel not available, that's okay
}
$registry = new ComponentRegistry(
return new ComponentRegistry(
container: $this->container,
discoveryRegistry: $this->discoveryRegistry,
renderer: $renderer,
@@ -49,10 +49,5 @@ final readonly class ComponentRegistryInitializer
performanceTracker: $performanceTracker,
debugPanel: $debugPanel
);
// Register as interface
$this->container->singleton(ComponentRegistryInterface::class, $registry);
return $registry;
}
}

View File

@@ -18,10 +18,8 @@ use App\Framework\Logging\Handlers\DockerJsonHandler;
use App\Framework\Logging\Handlers\FileHandler;
use App\Framework\Logging\Handlers\MultiFileHandler;
use App\Framework\Logging\Handlers\NullHandler;
use App\Framework\Logging\Handlers\QueuedLogHandler;
use App\Framework\Logging\LogHandler;
use App\Framework\Queue\Queue;
use App\Framework\Queue\RedisQueue;
use App\Framework\Queue\FileQueue;
use App\Framework\Redis\RedisConfig;
use App\Framework\Redis\RedisConnection;
@@ -46,7 +44,7 @@ final readonly class LoggerInitializer
$processorManager = new ProcessorManager();
$minLevel = $this->determineMinLogLevel($config);
$logConfig = $this->initializeLogConfig($pathProvider);
$queue = $this->createQueue($env);
$queue = $this->createQueue($pathProvider);
$handlers = $this->createHandlers($config, $env, $logConfig, $pathProvider, $minLevel, $queue);
$contextManager = $container->get(LogContextManager::class);
$clock = $container->get(Clock::class);
@@ -118,16 +116,15 @@ final readonly class LoggerInitializer
/**
* Erstellt die Queue für asynchrones Logging
*/
private function createQueue(Environment $env): Queue
private function createQueue(PathProvider $pathProvider): Queue
{
$redisConfig = RedisConfig::fromEnvironment($env);
$redisConnection = new RedisConnection($redisConfig, 'queue');
#$redisConfig = RedisConfig::fromEnvironment($env);
#$redisConnection = new RedisConnection($redisConfig, 'queue');
return new RedisQueue($redisConnection, 'commands');
#return new RedisQueue($redisConnection, 'commands');
// Alternativ: FileQueue mit aufgelöstem Pfad
// $queuePath = $pathProvider->resolvePath('storage/queue');
// return new FileQueue($queuePath);
$queuePath = $pathProvider->resolvePath('storage/queue');
return new FileQueue($queuePath);
}
/**