Update workers setup
This commit is contained in:
36
src/Managing.Application.Workers/SpotlightWorker.cs
Normal file
36
src/Managing.Application.Workers/SpotlightWorker.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Managing.Application.Workers;
|
||||
|
||||
public class SpotlightWorker : BaseWorker<SpotlightWorker>
|
||||
{
|
||||
private readonly IStatisticService _statisticService;
|
||||
|
||||
public SpotlightWorker(
|
||||
ILogger<SpotlightWorker> logger,
|
||||
IWorkerService workerService,
|
||||
IStatisticService statisticService) : base(
|
||||
Enums.WorkerType.Spotlight,
|
||||
logger,
|
||||
TimeSpan.FromMinutes(5),
|
||||
workerService)
|
||||
{
|
||||
_statisticService = statisticService;
|
||||
}
|
||||
|
||||
protected override async Task Run(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _statisticService.UpdateSpotlight();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("Enable to update spotlight", ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user