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:
@@ -0,0 +1,12 @@
|
||||
namespace NzbDrone.Common.Messaging
|
||||
{
|
||||
public class CommandCompletedEvent : IEvent
|
||||
{
|
||||
public ICommand Command { get; private set; }
|
||||
|
||||
public CommandCompletedEvent(ICommand command)
|
||||
{
|
||||
Command = command;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Common.Messaging
|
||||
{
|
||||
public class CommandFailedEvent : IEvent
|
||||
{
|
||||
public ICommand Command { get; private set; }
|
||||
public Exception Exception { get; private set; }
|
||||
|
||||
public CommandFailedEvent(ICommand command, Exception exception)
|
||||
{
|
||||
Command = command;
|
||||
Exception = exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace NzbDrone.Common.Messaging
|
||||
{
|
||||
public class CommandExecutedEvent : IEvent
|
||||
{
|
||||
public ICommand Command { get; private set; }
|
||||
|
||||
public CommandExecutedEvent(ICommand command)
|
||||
{
|
||||
Command = command;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,16 +75,23 @@ namespace NzbDrone.Common.Messaging
|
||||
|
||||
try
|
||||
{
|
||||
handlerContract.GetMethod("Execute").Invoke(handler, new object[] { command });
|
||||
handlerContract.GetMethod("Execute").Invoke(handler, new object[] {command});
|
||||
PublishEvent(new CommandCompletedEvent(command));
|
||||
}
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
PublishEvent(new CommandFailedEvent(command, e));
|
||||
|
||||
if (e.InnerException != null)
|
||||
{
|
||||
throw e.InnerException;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
PublishEvent(new CommandExecutedEvent(command));
|
||||
}
|
||||
|
||||
_logger.Debug("{0} <- {1}", command.GetType().Name, handler.GetType().Name);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace NzbDrone.Common.Messaging
|
||||
{
|
||||
public class TestCommand : ICommand
|
||||
{
|
||||
public TestCommand()
|
||||
{
|
||||
Duration = 4000;
|
||||
}
|
||||
|
||||
public int Duration { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace NzbDrone.Common.Messaging
|
||||
{
|
||||
public class TestCommandExecutor : IExecute<TestCommand>
|
||||
{
|
||||
public void Execute(TestCommand message)
|
||||
{
|
||||
Thread.Sleep(message.Duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user