Абанин Иван Лаб. 2 Группа 6512#115
Open
UselessMiva wants to merge 4 commits intoitsecd:mainfrom
Open
Conversation
Author
|
@Gwymlas, можете, пожалуйста, посмотреть pr? |
Gwymlas
requested changes
May 1, 2026
Comment on lines
+13
to
+14
| private static int _currentIndex = -1; | ||
| private static int _remainingRequests = 0; |
| private static int _remainingRequests = 0; | ||
| private static readonly object _lock = new(); | ||
|
|
||
| public string Type => "WeightedRoundRobin"; |
Comment on lines
+54
to
+62
| builder.Services.AddCors(options => | ||
| { | ||
| options.AddPolicy("AllowAll", policy => | ||
| { | ||
| policy.AllowAnyOrigin() | ||
| .AllowAnyMethod() | ||
| .AllowAnyHeader(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Настроить 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") }); |
There was a problem hiding this comment.
Это вроде уже делает 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); |
| // Добавляем клиентский проект | ||
| builder.AddProject<Projects.Client_Wasm>("client-wasm") | ||
| .WaitFor(api); // ждем запуска API | ||
| .WithReference(gateway) |
| .Where(s => | ||
| { | ||
| var hostPort = $"{s.HostAndPort.DownstreamHost}:{s.HostAndPort.DownstreamPort}"; | ||
| var weight = hostPortWeights.TryGetValue(hostPort, out var w) ? w : 1; |
There was a problem hiding this comment.
Тут и ниже можно упростить:
var weight = hostPortWeights.GetValueOrDefault(hostPort, 1);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ФИО: Абанин Иван Николаевич

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