mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-19 21:44:30 -04:00
improvements to scheduler,
better parallelism on RSS fetch
This commit is contained in:
@@ -12,10 +12,9 @@ namespace NzbDrone.Core.Jobs
|
||||
public interface ITaskManager
|
||||
{
|
||||
IList<ScheduledTask> GetPending();
|
||||
void SetLastExecutionTime(int taskId);
|
||||
}
|
||||
|
||||
public class TaskManager : IHandle<ApplicationStartedEvent>, ITaskManager
|
||||
public class TaskManager : IHandle<ApplicationStartedEvent>, IHandleAsync<CommandExecutedEvent>, ITaskManager
|
||||
{
|
||||
private readonly IScheduledTaskRepository _scheduledTaskRepository;
|
||||
private readonly Logger _logger;
|
||||
@@ -32,11 +31,6 @@ namespace NzbDrone.Core.Jobs
|
||||
return _scheduledTaskRepository.All().Where(c => c.LastExecution.AddMinutes(c.Interval) < DateTime.UtcNow).ToList();
|
||||
}
|
||||
|
||||
public void SetLastExecutionTime(int taskId)
|
||||
{
|
||||
_scheduledTaskRepository.SetLastExecutionTime(taskId, DateTime.UtcNow);
|
||||
}
|
||||
|
||||
public void Handle(ApplicationStartedEvent message)
|
||||
{
|
||||
var defaultTasks = new[]
|
||||
@@ -72,5 +66,11 @@ namespace NzbDrone.Core.Jobs
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleAsync(CommandExecutedEvent message)
|
||||
{
|
||||
var commandId = _scheduledTaskRepository.GetDefinition(message.Command.GetType()).Id;
|
||||
_scheduledTaskRepository.SetLastExecutionTime(commandId, DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user