mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-25 14:01:13 +00:00
finished unit tests and docstrings
This commit is contained in:
@@ -8,13 +8,21 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MalwareMultiScan.Api.Services.Implementations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class ReceiverHostedService : IReceiverHostedService
|
||||
{
|
||||
private readonly IBus _bus;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ILogger<ReceiverHostedService> _logger;
|
||||
private readonly IScanResultService _scanResultService;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initialize receiver hosted service.
|
||||
/// </summary>
|
||||
/// <param name="bus">EasyNetQ bus.</param>
|
||||
/// <param name="configuration">Configuration.</param>
|
||||
/// <param name="scanResultService">Scan result service.</param>
|
||||
/// <param name="logger">Logger.</param>
|
||||
public ReceiverHostedService(IBus bus, IConfiguration configuration, IScanResultService scanResultService,
|
||||
ILogger<ReceiverHostedService> logger)
|
||||
{
|
||||
@@ -23,13 +31,15 @@ namespace MalwareMultiScan.Api.Services.Implementations
|
||||
_scanResultService = scanResultService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_bus.Receive<ScanResultMessage>(_configuration.GetValue<string>("ResultsSubscriptionId"), async message =>
|
||||
{
|
||||
message.Threats ??= new string[] { };
|
||||
|
||||
|
||||
_logger.LogInformation(
|
||||
$"Received a result from {message.Backend} for {message.Id} " +
|
||||
$"with threats {string.Join(",", message.Threats)}");
|
||||
@@ -44,7 +54,8 @@ namespace MalwareMultiScan.Api.Services.Implementations
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_bus?.Dispose();
|
||||
|
Reference in New Issue
Block a user