Skip to content

Сысолятин Егор Лаб. 1 Группа 6512#104

Open
RYTpL wants to merge 7 commits into
itsecd:mainfrom
RYTpL:lb1_var34
Open

Сысолятин Егор Лаб. 1 Группа 6512#104
RYTpL wants to merge 7 commits into
itsecd:mainfrom
RYTpL:lb1_var34

Conversation

@RYTpL
Copy link
Copy Markdown

@RYTpL RYTpL commented Apr 13, 2026

ФИО: Сысолятин Егор
Номер группы: 6512
Номер лабораторной: 1
Номер варианта: 34
Краткое описание предметной области: Программный проект
Краткое описание добавленных фич: Реализован сервис генерации контрактов на разработку ПО на основе Bogus с кэшированием ответов через IDistributedCache и Redis, структурным логированием через Serilog и оркестрацией через .NET Aspire.

@github-actions github-actions Bot added In progress Код в процессе проверки Lab 1 Лабораторная №1. Кэширование labels Apr 13, 2026
@github-actions github-actions Bot requested a review from Gwymlas April 13, 2026 12:35
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.

Для начала вычистить от ненужных проектов: CloudDevelopment.ApiService, CloudDevelopment.Web и так далее
Добавить в Aspire веб-интерфейс redis и клиент Client.Wasm, который шел изначально

@RYTpL
Copy link
Copy Markdown
Author

RYTpL commented Apr 18, 2026

Насколько я понял, вы смотрите не последнюю версию проекта. У меня там нет ни ApiService, ни Web. Есть и redis и Wasm. https://github.com/RYTpL/cloud-development/tree/lb1_var34

@Gwymlas
Copy link
Copy Markdown

Gwymlas commented Apr 23, 2026

CloudDevelopment.ApiService
CloudDevelopment.Web
CloudDevelopment.AppHost
и так далее. Этот код следует подчистить из репозитория, он никак не участвует в решении и является мусорным

В текущем AppHost нет веб-интерфейса для redis по типу redis insight или redis commander и Client.Wasm не запускается:

var builder = DistributedApplication.CreateBuilder(args);


var redis = builder.AddRedis("redis");


builder.AddProject<Projects.GenerationService>("generation-service")
    .WithReference(redis)      
    .WaitFor(redis);            

builder.Build().Run();

egors added 3 commits April 29, 2026 11:44
@RYTpL
Copy link
Copy Markdown
Author

RYTpL commented Apr 29, 2026

Сделал

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.

Сейчас клиент не обращается к сервису генерации, исправить
В StudentCard.razor заполнить данные

Comment thread CloudDevelopment/CloudDevelopment.AppHost/AppHost.cs Outdated
Comment thread CloudDevelopment/CloudDevelopment.AppHost/AppHost.cs Outdated
@@ -0,0 +1,17 @@
<Project Sdk="Aspire.AppHost.Sdk/13.2.2">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Использовать версию Aspire 9.5.2

Comment thread GenerationService/Models/SoftwareProjectContract.cs
string ProjectManager,
DateOnly StartDate,
DateOnly PlannedEndDate,
DateOnly ActualEndDate,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ActualEndDate по заданию должно быть DateOnly?

Comment thread GenerationService/Program.cs Outdated
var cacheKey = $"contract:{id}";

// Пробуем достать из кэша
var cached = await cache.GetStringAsync(cacheKey);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

GetStringAsync и SetStringAsync могут кинуть исключения, надо обернуть в try-catch

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Удалить

Comment thread Services.Contracts/Models/Contract.cs Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Удалить

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Удалить все в Service.Contracts

@RYTpL
Copy link
Copy Markdown
Author

RYTpL commented May 1, 2026

это поправил

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.

Клиент до сих пор не обращается к сервису

.WaitFor(redis);

builder.AddProject<Projects.Client_Wasm>("client-wasm")
.WithReference(generation)
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 не нужен

@@ -0,0 +1,17 @@
<Project Sdk="Aspire.AppHost.Sdk/13.2.2">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

<Project Sdk="Microsoft.NET.Sdk">

  <Sdk Name="Aspire.AppHost.Sdk" Version="9.5.2" />

Comment on lines +21 to +29
public ContractCacheService(
IDistributedCache cache,
ContractGeneratorService generator,
ILogger<ContractCacheService> logger)
{
_cache = cache;
_generator = generator;
_logger = logger;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Использовать праймари конструктор


private static readonly DistributedCacheEntryOptions _cacheOptions = new()
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

5 брать из appsettings

private readonly Faker _faker = new("ru");

// Id теперь принимается снаружи (от пользователя)
public SoftwareProjectContract Generate(int id)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Правила генерации лучше описывать при инициализации Faker, а не каждый раз при создании объекта

Comment on lines +29 to +31
var lastName = _faker.Name.LastName(Bogus.DataSets.Name.Gender.Male);
var firstName = _faker.Name.FirstName(Bogus.DataSets.Name.Gender.Male);
var middleName = _faker.Name.FirstName(Bogus.DataSets.Name.Gender.Male) + "ович";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Почему ProjectManager только мужчина

Comment on lines +22 to +24
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.

Настроить: добавить origin, разрешенные методы и хэдеры

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In progress Код в процессе проверки Lab 1 Лабораторная №1. Кэширование

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants