Further cleanup. Moved BackgroundJob Task enqueues into TaskScheduler, so I can have complete control via one interface.
This commit is contained in:
parent
825afd83a2
commit
26660a9bb3
7 changed files with 47 additions and 43 deletions
|
@ -6,19 +6,36 @@ namespace API.Services
|
|||
{
|
||||
public class TaskScheduler : ITaskScheduler
|
||||
{
|
||||
private readonly ICacheService _cacheService;
|
||||
private readonly ILogger<TaskScheduler> _logger;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IDirectoryService _directoryService;
|
||||
private readonly BackgroundJobServer _client;
|
||||
|
||||
public TaskScheduler(ICacheService cacheService, ILogger<TaskScheduler> logger)
|
||||
public TaskScheduler(ICacheService cacheService, ILogger<TaskScheduler> logger,
|
||||
IUnitOfWork unitOfWork, IDirectoryService directoryService)
|
||||
{
|
||||
_cacheService = cacheService;
|
||||
_logger = logger;
|
||||
_unitOfWork = unitOfWork;
|
||||
_directoryService = directoryService;
|
||||
_client = new BackgroundJobServer();
|
||||
|
||||
_logger.LogInformation("Scheduling/Updating cache cleanup on a daily basis.");
|
||||
RecurringJob.AddOrUpdate(() => cacheService.Cleanup(), Cron.Daily);
|
||||
RecurringJob.AddOrUpdate(() => _cacheService.Cleanup(), Cron.Daily);
|
||||
//RecurringJob.AddOrUpdate(() => scanService.ScanLibraries(), Cron.Daily);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ScanLibrary(int libraryId, bool forceUpdate = false)
|
||||
{
|
||||
_logger.LogInformation($"Enqueuing library scan for: {libraryId}");
|
||||
BackgroundJob.Enqueue(() => _directoryService.ScanLibrary(libraryId, forceUpdate));
|
||||
}
|
||||
|
||||
public void CleanupVolumes(int[] volumeIds)
|
||||
{
|
||||
BackgroundJob.Enqueue(() => _cacheService.CleanupVolumes(volumeIds));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue