Refactor messaging system to utilize LiteCqrs library
- Replaced instances of the previous messaging system with LiteCqrs across various application components, enhancing the CQRS implementation. - Updated dependency injection to register LiteCqrs services and behaviors, streamlining command and query handling. - Adjusted multiple command and query handlers to align with the new messaging framework, ensuring consistent functionality and improved maintainability. - Added LiteCqrs package reference in the project file for better dependency management.
This commit is contained in:
@@ -133,9 +133,14 @@ PnvPanel — backend на **ASP.NET Core (.NET 10)** по принципам **C
|
||||
|
||||
- **Команды** меняют состояние, возвращают `Result` / `Result<T>`; выполняются в транзакции (UnitOfWorkBehavior).
|
||||
- **Запросы** только читают; могут ходить в БД проекциями (`Select` в DTO) без загрузки сущностей целиком.
|
||||
- Диспетчер — **собственный тонкий `ISender`**: резолвит хендлер команды/запроса из DI и прогоняет
|
||||
через pipeline behaviors. Без внешних CQRS-библиотек (MediatR/и т.п.). Абстракции — `ICommand<T>`,
|
||||
`IQuery<T>`, `ICommandHandler<,>`, `IQueryHandler<,>`, `IPipelineBehavior<,>`.
|
||||
- Диспетчер — `ISender` из [`LiteCqrs.Net`](https://github.com/mrleo1nid/LiteCqrs.Net) (собственная
|
||||
лёгкая CQRS-библиотека, альтернатива MediatR с явным разделением Command/Query — сосед-репозиторий
|
||||
в `D:\Github`, пока подключён `ProjectReference`'ом, не через NuGet): резолвит хендлер
|
||||
команды/запроса из DI (dynamic-free кэшированный диспетчер) и прогоняет через pipeline behaviors.
|
||||
Абстракции — `ICommand<T>`, `IQuery<T>`, `ICommandHandler<,>`, `IQueryHandler<,>`,
|
||||
`IPipelineBehavior<,>` — все из `LiteCqrs`; PnvPanel-специфичные behaviors (`ValidationBehavior`,
|
||||
`RequireActivationBehavior`, `UnitOfWorkBehavior`) и маркер `IRequiresActivation` остаются в
|
||||
`Application/Common/Behaviors`.
|
||||
|
||||
Пример потока «создать конфиг» (`backend/src/PnvPanel.Application/Configs/Create/CreateVpnConfigCommandHandler.cs`):
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user