Skip to content

Абанин Иван Лаб. 2 Группа 6512#115

Open
UselessMiva wants to merge 4 commits intoitsecd:mainfrom
UselessMiva:main
Open

Абанин Иван Лаб. 2 Группа 6512#115
UselessMiva wants to merge 4 commits intoitsecd:mainfrom
UselessMiva:main

Conversation

@UselessMiva
Copy link
Copy Markdown

ФИО: Абанин Иван Николаевич
Номер группы: 6512
Номер лабораторной: 2
Номер варианта: 19
Краткое описание предметной области: «Объект жилого строительства»
Краткое описание добавленных фич: Добавлен балансер
Weighted Round Robin и Ocelot Gateway
image

image

@github-actions github-actions Bot added In progress Код в процессе проверки Lab 2 Лабораторная №2. Балансировка нагрузки labels Apr 16, 2026
@github-actions github-actions Bot requested a review from Gwymlas April 16, 2026 00:25
@UselessMiva
Copy link
Copy Markdown
Author

@Gwymlas, можете, пожалуйста, посмотреть pr?

Copy link
Copy Markdown

@Gwymlas Gwymlas left a comment

Choose a reason for hiding this comment

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

Код лабораторной совпадает с другим пр

Comment on lines +13 to +14
private static int _currentIndex = -1;
private static int _remainingRequests = 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.

Не думаю что нужен static

private static int _remainingRequests = 0;
private static readonly object _lock = new();

public string Type => "WeightedRoundRobin";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Использовать nameof

Comment on lines +54 to +62
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll", policy =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Настроить Cors
Убрать Cors из кода сервиса (в ResidentialProperty.Api/Program.cs)

Comment on lines +67 to +68
app.UseHealthChecks("/health");
app.UseHealthChecks("/alive", new HealthCheckOptions { Predicate = r => r.Tags.Contains("live") });
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Это вроде уже делает app.MapDefaultEndpoints();

Comment on lines +8 to +39
var api0 = builder.AddProject<Projects.ResidentialProperty_Api>("residentialproperty-api-0")
.WithReference(redis)
.WithEnvironment("ASPNETCORE_URLS", "http://localhost:7283")
.WithEndpoint("http", endpoint =>
{
endpoint.IsProxied = false;
endpoint.Port = 7283;
endpoint.TargetPort = 7283;
})
.WaitFor(redis);

var api1 = builder.AddProject<Projects.ResidentialProperty_Api>("residentialproperty-api-1")
.WithReference(redis)
.WithEnvironment("ASPNETCORE_URLS", "http://localhost:7284")
.WithEndpoint("http", endpoint =>
{
endpoint.IsProxied = false;
endpoint.Port = 7284;
endpoint.TargetPort = 7284;
})
.WaitFor(redis);

var api2 = builder.AddProject<Projects.ResidentialProperty_Api>("residentialproperty-api-2")
.WithReference(redis)
.WaitFor(redis); // ждем запуска Redis
.WithEnvironment("ASPNETCORE_URLS", "http://localhost:7285")
.WithEndpoint("http", endpoint =>
{
endpoint.IsProxied = false;
endpoint.Port = 7285;
endpoint.TargetPort = 7285;
})
.WaitFor(redis);
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.AddProject<Projects.Client_Wasm>("client-wasm")
.WaitFor(api); // ждем запуска API
.WithReference(gateway)
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 не нужен

.Where(s =>
{
var hostPort = $"{s.HostAndPort.DownstreamHost}:{s.HostAndPort.DownstreamPort}";
var weight = hostPortWeights.TryGetValue(hostPort, out var w) ? w : 1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Тут и ниже можно упростить:
var weight = hostPortWeights.GetValueOrDefault(hostPort, 1);

@Gwymlas Gwymlas added Stolen Вы уличены в краже кода. Вы покрыли себя несмываемым позором and removed In progress Код в процессе проверки labels May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Lab 2 Лабораторная №2. Балансировка нагрузки Stolen Вы уличены в краже кода. Вы покрыли себя несмываемым позором

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants