Skip to content

Чукарев Михаил Лаб. 2 Группа 6511#81

Open
Mishachuu wants to merge 22 commits intoitsecd:mainfrom
Mishachuu:main
Open

Чукарев Михаил Лаб. 2 Группа 6511#81
Mishachuu wants to merge 22 commits intoitsecd:mainfrom
Mishachuu:main

Conversation

@Mishachuu
Copy link
Copy Markdown

ФИО: Чукарев Михаил
Номер группы: 6511
Номер лабораторной: 2
Номер варианта: 17
Краткое описание предметной области: Транспортное средство
Краткое описание добавленных фич:

  • Реализован алгоритм балансировки QueryBased
  • Реализован ApiGateway и подняты три реплики сервиса генерации

@github-actions github-actions Bot added In progress Код в процессе проверки Lab 2 Лабораторная №2. Балансировка нагрузки labels Apr 1, 2026
@github-actions github-actions Bot requested a review from danlla April 1, 2026 07:33
Comment thread Client.Wasm/Components/StudentCard.razor Outdated
Comment thread src/VehicleApi/Program.cs Outdated
public Task<Response<ServiceHostAndPort>> LeaseAsync(HttpContext httpContext)
{
var cumulative = 0.0;
var roll = Random.Shared.NextDouble();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно тут домножать на сумму элементов weights, которую по-хорошему вынести в приватное поле

Тогда не нужно будет следить за тем, что сумма весов равна 1

Comment thread src/ApiGateway/LoadBalancing/WeightedRandomLoadBalancer.cs Outdated
Comment thread src/ApiGateway/Program.cs
Comment thread src/ApiGateway/appsettings.json Outdated
Comment thread src/AppHost/Program.cs
Comment thread src/AppHost/appsettings.json Outdated
Comment thread src/AppHost/Program.cs Outdated
.WithHttpEndpoint(port: port, name: "api-endpoint", isProxied: false)
.WithExternalHttpEndpoints();

gateway.WaitFor(replica);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Здесь не хватает .WithReference(replica), чтобы aspire прокинул адрес апи в api gateway

Если в aspire поменять порты, то все должно работать, api gateway проект должен достать из переменных окружения, которые пришли от aspire, адреса сервисов и поменять конфигурацию самого api gateway

Comment thread README.md
@Mishachuu Mishachuu requested a review from danlla April 14, 2026 19:42
Copy link
Copy Markdown

@danlla danlla left a comment

Choose a reason for hiding this comment

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

Если в aspire поменять порты у replica, то все перестанет работать, потому что сейчас все завязано на то, что написано в файле ocelot.json, нужно сделать так, чтобы эта конфигурация переопределялась, если в переменных окружения есть адреса сервисов, которые aspire туда будет прокидывать при использовании WithReference

@Mishachuu Mishachuu requested a review from danlla April 16, 2026 07:30
Comment thread src/ApiGateway/Program.cs Outdated

for (var i = 1; ; i++)
{
var url = builder.Configuration[$"services__vehicleapi-{i}__http__0"];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если посмотреть по трассировкам, то сейчас только один сервис обрабатывает все запросы
Здесь нужно указать: builder.Configuration[$"services:vehicleapi-{i}:api-endpoint:0"], так как эндпоинт в aspire назван как api-endpoint

В виде $"services__vehicleapi-{i}__http__0" у меня не запустилось нормально, такой переменной не находит в конфигурации

Comment thread src/ApiGateway/Program.cs Outdated
{
options.AddDefaultPolicy(policy =>
{
policy.AllowAnyOrigin()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Здесь стоит использовать origins клиента вместо AllowAnyOrigin

@Mishachuu Mishachuu requested a review from danlla April 20, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In progress Код в процессе проверки Lab 2 Лабораторная №2. Балансировка нагрузки

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants