using PARR.NextRun;

namespace PARR.NextRunWorker
{
    public class IntervalWorker : BackgroundService
    {
        private readonly INextRunIntervalService nextRunIntervalService;
        private readonly ILogger<IntervalWorker> logger;

        public IntervalWorker(INextRunIntervalService nextRunIntervalService, ILogger<IntervalWorker> logger)
        {
            this.nextRunIntervalService = nextRunIntervalService;
            this.logger = logger;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            logger.LogInformation("Запуск {workerName}", nameof(IntervalWorker));
            await nextRunIntervalService.StartAsync();
        }
    }
}
