using PARR.TemplateMatcher;

namespace PARR.TemplateMatcherWorker
{
    public class Worker : BackgroundService
    {
        private readonly ILogger<Worker> _logger;
        private readonly IMqTemplateMatcher mqTemplateMatcher;

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

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


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