finalize refactoring & ready for the PR

This commit is contained in:
Volodymyr Smirnov
2020-10-26 21:24:40 +02:00
parent 14c9c26979
commit 62cdcdbb49
34 changed files with 229 additions and 164 deletions

View File

@@ -56,28 +56,35 @@ namespace MalwareMultiScan.Scanner.Services
var cancellationTokenSource = new CancellationTokenSource(
TimeSpan.FromSeconds(_configuration.GetValue<int>("MaxScanningTime")));
var result = new ScanResultMessage
{
Id = message.Id,
Backend = _backend.Id
};
try
{
var result = new ScanResultMessage
{
Id = message.Id,
Backend = _backend.Id,
result.Threats = await _backend.ScanAsync(
message.Uri, cancellationTokenSource.Token);
Threats = await _backend.ScanAsync(
message.Uri, cancellationTokenSource.Token)
};
result.Succeeded = true;
_logger.LogInformation(
$"Backend {_backend.Id} completed a scan of {message.Id} " +
$"with result '{string.Join(", ", result.Threats)}'");
await _bus.SendAsync(_configuration.GetValue<string>("ResultsSubscriptionId"), result);
}
catch (Exception exception)
{
result.Succeeded = false;
_logger.LogError(
exception, "Scanning failed with exception");
}
finally
{
await _bus.SendAsync(
_configuration.GetValue<string>("ResultsSubscriptionId"), result);
}
}
}
}