<?php

namespace NoahVet\Reef\RabbitMQ\Consumer\Factory;

use NoahVet\Reef\RabbitMQ\Consumer\ReefMQConsumer;
use NoahVet\Reef\RabbitMQ\Consumer\ReefMQConsumerInterface;
use NoahVet\Reef\RabbitMQ\Message\Handler\ReefAMQPMessageHandlerInterface;
use NoahVet\Reef\RabbitMQ\RabbitMQConnectionFactoryInterface;
use Psr\Log\LoggerInterface;

class ReefMQConsumerFactory implements ReefMQConsumerFactoryInterface
{
    public function __construct(
        protected readonly ReefAMQPMessageHandlerInterface $messageHandler,
        protected readonly RabbitMQConnectionFactoryInterface $rabbitMQConnectionFactory,
        protected readonly LoggerInterface $reefConsumerLogger,
        protected readonly string $reefAppName,
    ) {
    }

    #[\Override]
    public function createConsumer(): ReefMQConsumerInterface
    {
        return new ReefMQConsumer(
            $this->rabbitMQConnectionFactory->get(),
            $this->messageHandler,
            $this->reefConsumerLogger,
            $this->reefAppName,
        );
    }
}
