Skip to content

Conversation

@AnnaVerh04
Copy link

ФИО: Верховая Анна
Номер группы: 6413
Номер лабораторной: 4
Номер варианта: 61
Краткое описание предметной области: Риэлторское агентство
Краткое описание добавленных фич: Добавлен генератор тестовых данных, отправляющий контрагентов и объекты недвижимости через NATS. WebAPI получает сообщения фоновым сервисом и сохраняет в MongoDB. Реализованы retry-механизмы для подключений к БД и NATS. Вся инфраструктура оркестрируется через .NET Aspire AppHost.

@github-actions github-actions bot added In progress Код в процессе проверки Lab 4 Лабораторная №4. Инфраструктура labels Dec 25, 2025
Copy link

@DmitryKrakhmalev DmitryKrakhmalev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Есть замечания которые необходимо устранить и запросить повторный ревью.
Запрос на ревью принимаю только до 20:00 - если не успеете оценка понизится

Comment on lines 8 to 12
public class DataGeneratorService(
NatsPublisher natsPublisher,
ILogger<DataGeneratorService> logger,
int batchSize = 10,
int delayBetweenBatchesMs = 5000) : BackgroundService

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вы планируете работать с данным классом не через DI? Так то он должен регистрироваться как HostedService.
Не очень понимаю зачем в конструктор подавать batchSize и delayBetweenBatchedMs - берите их из конфига.
Оптимальный конечно же вариант как IOptions, ну тут как уж реализуете.

@@ -0,0 +1,43 @@
using RealEstateAgency.Generator.Services;

var builder = Host.CreateApplicationBuilder(args);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddServiceDefaults

@AnnaVerh04
Copy link
Author

Снимок экрана 2025-12-26 183544
Постаралась исправить замечания, но generator не может подключится к nuts
Отдельно nuts запускала

Copy link

@DmitryKrakhmalev DmitryKrakhmalev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Засчитываю работу. Данные генерируются. По сути проблема в одной строчке.

// Generator
builder.AddProject<Projects.RealEstateAgency_Generator>("generator")
.WithReference(nats)
.WaitFor(nats)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом если вам нужны какие то адреса - можно просто через переменные окружения их пробрасывать:

Suggested change
.WaitFor(nats)
.WaitFor(nats)
.WithEnvironment("Nats__Url",nats.GetEndpoint("tcp"))

Тут же вам было бы достаточно обратиться к ConnectionString с именем "nats"


builder.AddServiceDefaults();

var natsConnectionString = "nats://localhost:4222";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что же вы мне раньше не написали я бы вам объяснил.

Suggested change
var natsConnectionString = "nats://localhost:4222";
var natsConnectionString = builder.Configuration.GetConnectionString("nats");
image

@DmitryKrakhmalev DmitryKrakhmalev added Approved Лабораторная зачтена and removed In progress Код в процессе проверки labels Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Лабораторная зачтена Lab 4 Лабораторная №4. Инфраструктура

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants