diff --git a/src/Recyclarr.Cli/CompositionRoot.cs b/src/Recyclarr.Cli/CompositionRoot.cs index e6f34300..f395b08c 100644 --- a/src/Recyclarr.Cli/CompositionRoot.cs +++ b/src/Recyclarr.Cli/CompositionRoot.cs @@ -15,6 +15,7 @@ using Recyclarr.Cli.Pipelines.MediaNaming; using Recyclarr.Cli.Pipelines.QualityProfile; using Recyclarr.Cli.Pipelines.QualitySize; using Recyclarr.Cli.Processors; +using Recyclarr.Cli.Processors.Sync; using Recyclarr.Common; using Recyclarr.Compatibility; using Recyclarr.Config; @@ -76,6 +77,7 @@ public static class CompositionRoot builder.RegisterModule(); builder.RegisterGeneric(typeof(GenericPipelinePhases<>)); + builder.RegisterComposite(); builder.RegisterTypes( // ORDER HERE IS IMPORTANT! // There are indirect dependencies between pipelines. diff --git a/src/Recyclarr.Cli/Processors/ServiceProcessorsAutofacModule.cs b/src/Recyclarr.Cli/Processors/ServiceProcessorsAutofacModule.cs index e88d3bea..b6172e55 100644 --- a/src/Recyclarr.Cli/Processors/ServiceProcessorsAutofacModule.cs +++ b/src/Recyclarr.Cli/Processors/ServiceProcessorsAutofacModule.cs @@ -18,7 +18,6 @@ public class ServiceProcessorsAutofacModule : Module // Sync builder.RegisterType().As(); - builder.RegisterType(); // Configuration builder.RegisterType().As(); diff --git a/src/Recyclarr.Cli/Processors/Sync/SyncPipelineExecutor.cs b/src/Recyclarr.Cli/Processors/Sync/CompositeSyncPipeline.cs similarity index 54% rename from src/Recyclarr.Cli/Processors/Sync/SyncPipelineExecutor.cs rename to src/Recyclarr.Cli/Processors/Sync/CompositeSyncPipeline.cs index c7b4c727..10123fcb 100644 --- a/src/Recyclarr.Cli/Processors/Sync/SyncPipelineExecutor.cs +++ b/src/Recyclarr.Cli/Processors/Sync/CompositeSyncPipeline.cs @@ -2,21 +2,19 @@ using Recyclarr.Cli.Console.Settings; using Recyclarr.Cli.Pipelines; using Recyclarr.Compatibility; using Recyclarr.Config.Models; -using Spectre.Console; namespace Recyclarr.Cli.Processors.Sync; -public class SyncPipelineExecutor( +public class CompositeSyncPipeline( ILogger log, - IAnsiConsole console, IOrderedEnumerable pipelines, IEnumerable caches, ServiceAgnosticCapabilityEnforcer enforcer, - IServiceConfiguration config) + IServiceConfiguration config) : ISyncPipeline { - public async Task Process(ISyncSettings settings, CancellationToken ct) + public virtual async Task Execute(ISyncSettings settings, CancellationToken ct) { - PrintProcessingHeader(); + log.Debug("Processing {Server} server {Name}", config.ServiceType, config.InstanceName); await enforcer.Check(config, ct); @@ -32,20 +30,4 @@ public class SyncPipelineExecutor( log.Information("Completed at {Date}", DateTime.Now); } - - private void PrintProcessingHeader() - { - var instanceName = config.InstanceName; - - console.WriteLine( - $""" - - =========================================== - Processing {config.ServiceType} Server: [{instanceName}] - =========================================== - - """); - - log.Debug("Processing {Server} server {Name}", config.ServiceType, instanceName); - } } diff --git a/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs b/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs index 7215b46e..356d5d49 100644 --- a/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs +++ b/src/Recyclarr.Cli/Processors/Sync/SyncProcessor.cs @@ -1,19 +1,23 @@ using System.Diagnostics.CodeAnalysis; using Autofac; using Recyclarr.Cli.Console.Settings; +using Recyclarr.Cli.Pipelines; using Recyclarr.Cli.Processors.ErrorHandling; using Recyclarr.Config; using Recyclarr.Config.Models; +using Spectre.Console; namespace Recyclarr.Cli.Processors.Sync; +[UsedImplicitly] public class SyncBasedConfigurationScope(ILifetimeScope scope) : ConfigurationScope(scope) { - public SyncPipelineExecutor Pipelines { get; } = scope.Resolve(); + public ISyncPipeline Pipelines { get; } = scope.Resolve(); } [SuppressMessage("Design", "CA1031:Do not catch general exception types")] public class SyncProcessor( + IAnsiConsole console, IConfigurationRegistry configRegistry, ConfigurationScopeFactory configScopeFactory, ConsoleExceptionHandler exceptionHandler) @@ -59,7 +63,17 @@ public class SyncProcessor( try { using var scope = configScopeFactory.Start(config); - await scope.Pipelines.Process(settings, ct); + + console.WriteLine( + $""" + + =========================================== + Processing {config.ServiceType} Server: [{config.InstanceName}] + =========================================== + + """); + + await scope.Pipelines.Execute(settings, ct); } catch (Exception e) {