Панкеев Глеб Лаб. 2 Группа 6512#97
Open
Pancake2021 wants to merge 16 commits into
Open
Conversation
…ю на вариант №30 (Кредитная заявка, Query Based, SQS, Localstack)
Author
Author
Author
Author
Author
Author
Gwymlas
requested changes
Apr 17, 2026
Gwymlas
left a comment
There was a problem hiding this comment.
Дублируются проекты CreditSystem.* и ProjectApp.*, оставьте только необходимое (сейчас запускаются проекты ProjectApp.*)
Для первой и второй лабы localstack не нужен
- «Кэширование» - Реализация сервиса генерации контрактов, кэширование его ответов
В рамках первой лабораторной работы необходимо:
- Реализовать сервис генерации контрактов на основе Bogus,
- Реализовать кеширование при помощи IDistributedCache и Redis,
- Реализовать структурное логирование сервиса генерации,
- Настроить оркестрацию Aspire.
- «Балансировка нагрузки» - Реализация апи гейтвея, настройка его работы
В рамках второй лабораторной работы необходимо:
- Настроить оркестрацию на запуск нескольких реплик сервиса генерации,
- Реализовать апи гейтвей на основе Ocelot,
- Имплементировать алгоритм балансировки нагрузки согласно варианту.
Redis нет, при запросе по одному и тому же id выдает разные данные
Добавить summary, где отсутствует
Приведите лабораторную работу в порядок
Gwymlas
requested changes
May 11, 2026
| /// <param name="cancellationToken">Токен отмены операции</param> | ||
| /// <returns>Кредитная заявка</returns> | ||
| [HttpGet] | ||
| public async Task<ActionResult<CreditApplication>> GetById([FromQuery] int id, CancellationToken cancellationToken) |
Comment on lines
+20
to
+21
| var nonTerminalStatuses = new[] { "Новая", "В обработке" }; | ||
| var terminalStatuses = new[] { "Одобрена", "Отклонена" }; |
There was a problem hiding this comment.
Думаю стоит вынести в private static readonly поля
| var maxApplicationDate = DateTime.Today.AddDays(-1); | ||
|
|
||
| _faker = new Faker<CreditApplication>("ru") | ||
| .RuleFor(c => c.Id, f => f.IndexFaker + 1) |
There was a problem hiding this comment.
Id будет заполняться запрошенным значением, можно убрать
| ILogger<CreditApplicationService> logger) : ICreditApplicationService | ||
| { | ||
| private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web); | ||
| private static readonly TimeSpan CacheTtl = TimeSpan.FromMinutes(10); |
There was a problem hiding this comment.
В appsettings есть ExpirationMinutes, но его не используешь
Comment on lines
+31
to
+53
| var cachedPayload = await cache.GetStringAsync(cacheKey, cancellationToken); | ||
| if (!string.IsNullOrEmpty(cachedPayload)) | ||
| { | ||
| var cachedApplication = JsonSerializer.Deserialize<CreditApplication>(cachedPayload, JsonOptions); | ||
| if (cachedApplication is not null && validator.TryValidate(cachedApplication, out _)) | ||
| { | ||
| logger.LogInformation("Cache hit for credit application {Id}", id); | ||
| return cachedApplication; | ||
| } | ||
|
|
||
| if (cachedApplication is null) | ||
| { | ||
| logger.LogWarning("Cache entry for credit application {Id} cannot be deserialized. Regenerating value.", id); | ||
| } | ||
| else | ||
| { | ||
| validator.TryValidate(cachedApplication, out var cacheValidationError); | ||
| logger.LogWarning( | ||
| "Cache entry for credit application {Id} is invalid: {ValidationError}. Regenerating value.", | ||
| id, | ||
| cacheValidationError); | ||
| } | ||
| } |
Comment on lines
+5
to
+18
| var apiReplica1 = builder.AddProject<Projects.ProjectApp_Api>("projectapp-api-r1") | ||
| .WithReference(cache) | ||
| .WaitFor(cache) | ||
| .WithEndpoint("http", endpoint => endpoint.Port = 7001); | ||
|
|
||
| var apiReplica2 = builder.AddProject<Projects.ProjectApp_Api>("projectapp-api-r2") | ||
| .WithReference(cache) | ||
| .WaitFor(cache) | ||
| .WithEndpoint("http", endpoint => endpoint.Port = 7002); | ||
|
|
||
| var apiReplica3 = builder.AddProject<Projects.ProjectApp_Api>("projectapp-api-r3") | ||
| .WithReference(cache) | ||
| .WaitFor(cache) | ||
| .WithEndpoint("http", endpoint => endpoint.Port = 7003); |
| .WithEndpoint("http", endpoint => endpoint.Port = 7000); | ||
|
|
||
| builder.AddProject<Projects.Client_Wasm>("client") | ||
| .WithReference(gateway) |
| @@ -0,0 +1,52 @@ | |||
| using Ocelot.LoadBalancer; | |||
| /// </summary> | ||
| public class QueryBasedLoadBalancer(IServiceDiscoveryProvider serviceProvider) : ILoadBalancer | ||
| { | ||
| public string Type => "QueryBased"; |
Comment on lines
+23
to
+32
| Assert.Equal(first.Id, second.Id); | ||
| Assert.Equal(first.CreditType, second.CreditType); | ||
| Assert.Equal(first.RequestedAmount, second.RequestedAmount); | ||
| Assert.Equal(first.TermMonths, second.TermMonths); | ||
| Assert.Equal(first.InterestRate, second.InterestRate); | ||
| Assert.Equal(first.ApplicationDate, second.ApplicationDate); | ||
| Assert.Equal(first.RequiresInsurance, second.RequiresInsurance); | ||
| Assert.Equal(first.Status, second.Status); | ||
| Assert.Equal(first.DecisionDate, second.DecisionDate); | ||
| Assert.Equal(first.ApprovedAmount, second.ApprovedAmount); |
Author
|
в целом сделал 2 коммита
|
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
Номер варианта: 30
Краткое описание предметной области: Кредитная заявка
Краткое описание добавленных фич: Реализован балансировщик нагрузки QB