mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 13:10:13 -07:00
Command queue
New: Adding multiple series will queue them instead of running all at once New: Slower scheduled tasks won't be block others from running
This commit is contained in:
parent
446d470f53
commit
638e3ca898
66 changed files with 1151 additions and 636 deletions
|
|
@ -1,9 +1,9 @@
|
|||
using NLog.Config;
|
||||
using System;
|
||||
using NLog.Config;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Commands.Tracking;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
namespace NzbDrone.Core.ProgressMessaging
|
||||
|
|
@ -11,13 +11,13 @@ namespace NzbDrone.Core.ProgressMessaging
|
|||
public class ProgressMessageTarget : Target, IHandle<ApplicationStartedEvent>
|
||||
{
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly ITrackCommands _trackCommands;
|
||||
private readonly IManageCommandQueue _commandQueueManager;
|
||||
private static LoggingRule _rule;
|
||||
|
||||
public ProgressMessageTarget(IEventAggregator eventAggregator, ITrackCommands trackCommands)
|
||||
public ProgressMessageTarget(IEventAggregator eventAggregator, IManageCommandQueue commandQueueManager)
|
||||
{
|
||||
_eventAggregator = eventAggregator;
|
||||
_trackCommands = trackCommands;
|
||||
_commandQueueManager = commandQueueManager;
|
||||
}
|
||||
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
|
|
@ -26,27 +26,26 @@ namespace NzbDrone.Core.ProgressMessaging
|
|||
|
||||
if (IsClientMessage(logEvent, command))
|
||||
{
|
||||
command.SetMessage(logEvent.FormattedMessage);
|
||||
_commandQueueManager.SetMessage(command, logEvent.FormattedMessage);
|
||||
_eventAggregator.PublishEvent(new CommandUpdatedEvent(command));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Command GetCurrentCommand()
|
||||
private CommandModel GetCurrentCommand()
|
||||
{
|
||||
var commandId = MappedDiagnosticsContext.Get("CommandId");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(commandId))
|
||||
if (String.IsNullOrWhiteSpace(commandId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _trackCommands.GetById(commandId);
|
||||
return _commandQueueManager.Get(Convert.ToInt32(commandId));
|
||||
}
|
||||
|
||||
private bool IsClientMessage(LogEventInfo logEvent, Command command)
|
||||
private bool IsClientMessage(LogEventInfo logEvent, CommandModel command)
|
||||
{
|
||||
if (command == null || !command.SendUpdatesToClient)
|
||||
if (command == null || !command.Body.SendUpdatesToClient)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -63,4 +62,4 @@ namespace NzbDrone.Core.ProgressMessaging
|
|||
LogManager.ReconfigExistingLoggers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue