basic architecture change: consul + hangfire

This commit is contained in:
Volodymyr Smirnov
2020-11-01 22:25:48 +02:00
parent 3f49c30b67
commit b918a82255
66 changed files with 571 additions and 728 deletions

View File

@@ -1,9 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using EasyNetQ;
using MalwareMultiScan.Backends.Backends.Implementations;
using MalwareMultiScan.Backends.Enums;
using MalwareMultiScan.Backends.Interfaces;
using MalwareMultiScan.Backends.Backends;
using MalwareMultiScan.Backends.Backends.Interfaces;
using MalwareMultiScan.Backends.Services.Implementations;
using MalwareMultiScan.Backends.Services.Interfaces;
using Microsoft.Extensions.Configuration;
@@ -17,55 +15,42 @@ namespace MalwareMultiScan.Backends.Extensions
[ExcludeFromCodeCoverage]
public static class ServiceCollectionExtensions
{
/// <summary>
/// Add RabbitMQ service.
/// </summary>
/// <param name="services">Service collection.</param>
/// <param name="configuration">Configuration.</param>
public static void AddRabbitMq(this IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton(x =>
RabbitHutch.CreateBus(configuration.GetConnectionString("RabbitMQ")));
}
/// <summary>
/// Add scanning backend.
/// </summary>
/// <param name="services">Service collection.</param>
/// <param name="configuration">Configuration.</param>
/// <exception cref="ArgumentOutOfRangeException">Unknown backend.</exception>
public static void AddScanningBackend(this IServiceCollection services, IConfiguration configuration)
public static void AddScanBackend(this IServiceCollection services, IConfiguration configuration)
{
services.AddSingleton<IProcessRunner, ProcessRunner>();
switch (configuration.GetValue<BackendType>("BackendType"))
switch (configuration.GetValue<string>("BACKEND_ID"))
{
case BackendType.Dummy:
services.AddSingleton<IScanBackend, DummyScanBackend>();
break;
case BackendType.Defender:
services.AddSingleton<IScanBackend, WindowsDefenderScanBackend>();
break;
case BackendType.Clamav:
case "clamav":
services.AddSingleton<IScanBackend, ClamavScanBackend>();
break;
case BackendType.DrWeb:
case "drweb":
services.AddSingleton<IScanBackend, DrWebScanBackend>();
break;
case BackendType.Kes:
case "kes":
services.AddSingleton<IScanBackend, KesScanBackend>();
break;
case BackendType.Comodo:
case "comodo":
services.AddSingleton<IScanBackend, ComodoScanBackend>();
break;
case BackendType.Sophos:
case "sophos":
services.AddSingleton<IScanBackend, SophosScanBackend>();
break;
case BackendType.McAfee:
case "mcafee":
services.AddSingleton<IScanBackend, McAfeeScanBackend>();
break;
case "windows-defender":
services.AddSingleton<IScanBackend, WindowsDefenderScanBackend>();
break;
default:
throw new ArgumentOutOfRangeException();
services.AddSingleton<IScanBackend, DummyScanBackend>();
break;
}
}
}