using PARR.TemplateActivator;

namespace PARR.TemplateActivatorWorker
{
    public class Worker : BackgroundService
    {
        private readonly ILogger<Worker> _logger;
        private readonly IMqTemplateActivator mqTemplateActivator;

        public Worker(ILogger<Worker> logger, IMqTemplateActivator mqTemplateActivator)
        {
            _logger = logger;
            this.mqTemplateActivator = mqTemplateActivator;
        }

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

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