mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:06:30 +00:00
big refactoring. get rid of static properties and coupled architecture. prepare system for integration tests
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user