<?php

declare(strict_types=1);

namespace App\Framework\Queue\Initializers;

use App\Framework\Database\ConnectionInterface;
use App\Framework\DI\Container;
use App\Framework\DI\Initializer;
use App\Framework\Logging\Logger;
use App\Framework\Queue\Services\JobMetricsManagerInterface;
use App\Framework\Queue\Services\ProductionJobMetricsManager;

final readonly class JobMetricsInitializer
{
    #[Initializer]
    public function __invoke(Container $container): JobMetricsManagerInterface
    {
        $connection = $container->get(ConnectionInterface::class);
        $logger = $container->get(Logger::class);

        $jobMetricsManager = new ProductionJobMetricsManager(
            connection: $connection,
            logger: $logger
        );

        // Framework will auto-register concrete class
        $container->instance(ProductionJobMetricsManager::class, $jobMetricsManager);
        $container->bind('job_metrics_manager', $jobMetricsManager);

        return $jobMetricsManager;
    }
}
