- 新增 GatewayAggregate 领域实体 (GwTenant, GwTenantRoute, GwServiceInstance) - 新增 IRouteStore, RouteStore, IInstanceStore, InstanceStore - 新增 IRouteManager, RouteManager - 合并 GatewayDbContext 到 PlatformDbContext - 统一 Extensions.AddPlatformCore 注册所有服务
5.0 KiB
5.0 KiB
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | must_haves | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-gateway-routing | 02 | execute | 1 |
|
true |
|
|
计划 02: 网关基础设施
目标
创建网关路由的基础设施层 - Store、Manager 和 DbContext。
目的: 实现数据访问和业务逻辑,遵循 Tenant 管理模式。
输出: GatewayDbContext、Store 接口/实现、Manager 接口/实现。
上下文
@Fengling.Platform.Infrastructure/Extensions.cs (DI 注册模式) @Fengling.Platform.Infrastructure/TenantStore.cs (Store 模式参考) @Fengling.Platform.Infrastructure/TenantManager.cs (Manager 模式参考) @../fengling-gateway/src/Data/GatewayDbContext.cs (源 DbContext)
任务
任务 1: 创建 GatewayDbContext Fengling.Platform.Infrastructure/GatewayDbContext.cs 创建继承 DbContext 的 GatewayDbContext: - 添加 DbSet GwTenants - 添加 DbSet GwTenantRoutes - 添加 DbSet GwServiceInstances - 在 OnModelCreating 中配置索引 (参考源 ../fengling-gateway)关键索引:
- GwTenant: TenantCode 唯一
- GwTenantRoute: TenantCode, ServiceName, ClusterId, 复合索引 (ServiceName, IsGlobal, Status)
- GwServiceInstance: 复合索引 (ClusterId, DestinationId) 唯一, Health 索引 dotnet build 通过 GatewayDbContext 包含所有 DbSet 和索引配置
创建实现 IRouteStore 的 RouteStore:
- 参考 TenantStore 模式
- 泛型约束: where TContext : GatewayDbContext
- 实现所有 CRUD 方法,支持软删除 dotnet build 通过 IRouteStore 接口和 RouteStore 实现
创建实现 IRouteManager 的 RouteManager:
- 参考 TenantManager 模式
- 构造函数: public RouteManager(IRouteStore store)
- 委托给 IRouteStore 进行数据操作 dotnet build 通过 IRouteManager 接口和 RouteManager 实现
创建实现 IInstanceStore 的 InstanceStore:
- 类似 RouteStore 的模式
- 重点在 ClusterId 和 DestinationId 查询 dotnet build 通过 IInstanceStore 接口和 InstanceStore 实现
验证
- GatewayDbContext 包含所有 DbSet 可编译
- Store 实现遵循 TenantStore 模式
- Manager 实现委托给 Stores
- Build 无错误通过
成功标准
基础设施层准备好进行 Extensions 集成。