big refactoring. get rid of static properties and coupled architecture. prepare system for integration tests

This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-11-17 13:14:05 +02:00
parent 22529c26ec
commit e7ea5a8ded
38 changed files with 808 additions and 157 deletions
+14 -3
View File
@@ -23,6 +23,8 @@ public class FailsafeAnnotationsProducer
private readonly IAzaionApi _azaionApi;
private readonly QueueConfig _queueConfig;
private readonly UIConfig _uiConfig;
private readonly IAnnotationPathResolver _pathResolver;
private readonly IFileSystem _fileSystem;
private Producer _annotationProducer = null!;
@@ -31,14 +33,23 @@ public class FailsafeAnnotationsProducer
IDbFactory dbFactory,
IOptions<QueueConfig> queueConfig,
IOptions<UIConfig> uiConfig,
IAzaionApi azaionApi)
IAzaionApi azaionApi,
IAnnotationPathResolver pathResolver,
IFileSystem fileSystem)
{
_logger = logger;
_dbFactory = dbFactory;
_azaionApi = azaionApi;
_queueConfig = queueConfig.Value;
_uiConfig = uiConfig.Value;
Task.Run(async () => await ProcessQueue());
_pathResolver = pathResolver;
_fileSystem = fileSystem;
}
public async Task StartAsync(CancellationToken ct = default)
{
_ = Task.Run(async () => await ProcessQueue(ct), ct);
await Task.CompletedTask;
}
private async Task<StreamSystem> GetProducerQueueConfig()
@@ -104,7 +115,7 @@ public class FailsafeAnnotationsProducer
continue;
var image = record.Operation == AnnotationStatus.Created
? await File.ReadAllBytesAsync(annotation.ImagePath, ct)
? await _fileSystem.ReadAllBytesAsync(_pathResolver.GetImagePath(annotation), ct)
: null;
var annMessage = new AnnotationMessage