using PARR.TemplateDistributor;

namespace PARR.TemplateDistributorWorker
{
    public class Worker : BackgroundService
    {
        private readonly IMqTemplateDistributor mqTemplateDistributor;

        public Worker(ILogger<Worker> logger, IMqTemplateDistributor mqTemplateDistributor)
        {
            this.mqTemplateDistributor = mqTemplateDistributor;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await mqTemplateDistributor.StartAsync();
            await Task.Delay(Timeout.Infinite, stoppingToken);
        }

        public override async Task StopAsync(CancellationToken cancellationToken)
        {
            await mqTemplateDistributor.StopAsync();
            await base.StopAsync(cancellationToken);
        }
    }
}
