mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:56:30 +00:00
add db WIP 2, 80%
refactor, renames
This commit is contained in:
@@ -8,6 +8,7 @@ using LinqToDB;
|
||||
using MessagePack;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using RabbitMQ.Stream.Client;
|
||||
using RabbitMQ.Stream.Client.Reliable;
|
||||
|
||||
@@ -28,14 +29,13 @@ public class FailsafeAnnotationsProducer
|
||||
_logger = logger;
|
||||
_dbFactory = dbFactory;
|
||||
_queueConfig = queueConfig.Value;
|
||||
Task.Run(async () => await ProcessQueue()).Wait();
|
||||
Task.Run(async () => await ProcessQueue());
|
||||
}
|
||||
|
||||
private async Task<StreamSystem> GetProducerQueueConfig()
|
||||
{
|
||||
return await StreamSystem.Create(new StreamSystemConfig
|
||||
{
|
||||
|
||||
Endpoints = new List<EndPoint> { new IPEndPoint(IPAddress.Parse(_queueConfig.Host), _queueConfig.Port) },
|
||||
UserName = _queueConfig.ProducerUsername,
|
||||
Password = _queueConfig.ProducerPassword
|
||||
@@ -45,7 +45,7 @@ public class FailsafeAnnotationsProducer
|
||||
private async Task Init(CancellationToken cancellationToken = default)
|
||||
{
|
||||
_annotationProducer = await Producer.Create(new ProducerConfig(await GetProducerQueueConfig(), Constants.MQ_ANNOTATIONS_QUEUE));
|
||||
//_annotationConfirmProducer = await Producer.Create(new ProducerConfig(await GetProducerQueueConfig(), Constants.MQ_ANNOTATIONS_CONFIRM_QUEUE));
|
||||
_annotationConfirmProducer = await Producer.Create(new ProducerConfig(await GetProducerQueueConfig(), Constants.MQ_ANNOTATIONS_CONFIRM_QUEUE));
|
||||
}
|
||||
|
||||
private async Task ProcessQueue(CancellationToken cancellationToken = default)
|
||||
@@ -98,7 +98,6 @@ public class FailsafeAnnotationsProducer
|
||||
foreach (var annotation in annotations)
|
||||
{
|
||||
var image = await File.ReadAllBytesAsync(annotation.ImagePath, cancellationToken);
|
||||
var label = await File.ReadAllTextAsync(annotation.LabelPath, cancellationToken);
|
||||
var annCreateMessage = new AnnotationCreatedMessage
|
||||
{
|
||||
Name = annotation.Name,
|
||||
@@ -108,7 +107,7 @@ public class FailsafeAnnotationsProducer
|
||||
CreatedDate = annotation.CreatedDate,
|
||||
|
||||
Image = image,
|
||||
Label = label,
|
||||
Detections = JsonConvert.SerializeObject(annotation.Detections),
|
||||
Source = annotation.Source
|
||||
};
|
||||
messages.Add(annCreateMessage);
|
||||
|
||||
Reference in New Issue
Block a user