<?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\Interfaces\DistributedLockInterface;
use App\Framework\Queue\Services\DatabaseDistributedLock;

/**
 * Distributed Lock Initializer
 */
final readonly class DistributedLockInitializer
{
    #[Initializer]
    public function __invoke(Container $container): DistributedLockInterface
    {
        $connection = $container->get(ConnectionInterface::class);
        $logger = $container->get(Logger::class);

        return new DatabaseDistributedLock(
            connection: $connection,
            logger: $logger
        );
    }
}
