26 lines
1004 B
C#
26 lines
1004 B
C#
using PARR.Core.Services.Workload.Interfaces;
|
|
using PARR.WorkloadBuilderWorker.Settings;
|
|
|
|
namespace PARR.WorkloadBuilderWorker
|
|
{
|
|
public class IntervalWorker : BackgroundService
|
|
{
|
|
private readonly ILogger<IntervalWorker> logger;
|
|
private readonly IWorkloadIntervalService workloadIntervalService;
|
|
private readonly WorkerSettings workerSettings;
|
|
|
|
public IntervalWorker(ILogger<IntervalWorker> logger, IWorkloadIntervalService workloadIntervalService, WorkerSettings workerSettings)
|
|
{
|
|
this.logger = logger;
|
|
this.workloadIntervalService = workloadIntervalService;
|
|
this.workerSettings = workerSettings;
|
|
}
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
logger.LogInformation("Запуск {workerName}", nameof(IntervalWorker));
|
|
await workloadIntervalService.StartAsync(workerSettings.RepeatEvery, workerSettings.MqSettings);
|
|
}
|
|
}
|
|
}
|