86 lines
3.1 KiB
Markdown
86 lines
3.1 KiB
Markdown
---
|
||
phase: "03-"
|
||
plan: 03
|
||
subsystem: Gateway
|
||
tags: [gateway, infrastructure, cluster, store, efcore]
|
||
dependency_graph:
|
||
requires: [GwCluster (来自计划 01)]
|
||
provides: [IClusterStore, ClusterStore, PlatformDbContext 更新]
|
||
affects: [Extensions, GatewayExtensions]
|
||
tech_stack:
|
||
added:
|
||
- IClusterStore 接口
|
||
- ClusterStore<TContext> 实现
|
||
patterns:
|
||
- Manager + Store 模式(ASP.NET Core Identity 风格)
|
||
- 泛型 DbContext 约束
|
||
- 软删除
|
||
- 内嵌集合使用 Owned Entity
|
||
key_files:
|
||
created:
|
||
- Fengling.Platform.Infrastructure/IClusterStore.cs
|
||
- Fengling.Platform.Infrastructure/ClusterStore.cs
|
||
modified:
|
||
- Fengling.Platform.Infrastructure/PlatformDbContext.cs
|
||
- Fengling.Platform.Infrastructure/Extensions.cs
|
||
- Fengling.Platform.Infrastructure/GatewayExtensions.cs
|
||
deleted:
|
||
- Fengling.Platform.Infrastructure/IInstanceStore.cs
|
||
- Fengling.Platform.Infrastructure/InstanceStore.cs
|
||
decisions:
|
||
- "IClusterStore 遵循 IRouteStore 模式以保持一致性"
|
||
- "ClusterStore 对 GwCluster 实体使用软删除"
|
||
- "OwnsMany 用于 EF Core 中内嵌的 Destinations 集合"
|
||
metrics:
|
||
duration: ""
|
||
completed_date: "2026-03-03"
|
||
---
|
||
|
||
# 阶段 03 - 计划 03: 网关基础设施更新总结
|
||
|
||
## 一句话概述
|
||
|
||
更新 PlatformDbContext 以包含 GwCluster DbSet 和 EF Core 配置,创建 IClusterStore/ClusterStore 以替代已废弃的 IInstanceStore/InstanceStore。
|
||
|
||
## 已完成任务
|
||
|
||
| 任务 | 名称 | 提交 | 文件 |
|
||
|------|------|------|------|
|
||
| 1 | 更新 PlatformDbContext | a655813 | PlatformDbContext.cs |
|
||
| 2 | 创建 IClusterStore 接口 | a655813 | IClusterStore.cs |
|
||
| 3 | 创建 ClusterStore 实现 | a655813 | ClusterStore.cs |
|
||
| 4 | 删除 IInstanceStore 和 InstanceStore | a655813 | IInstanceStore.cs, InstanceStore.cs (已删除) |
|
||
|
||
## 验证结果
|
||
|
||
- [x] PlatformDbContext 已更新 - 移除 GwTenant/GwServiceInstance DbSets,添加 GwCluster 及 EF Core 配置
|
||
- [x] IClusterStore 接口已创建,包含所有 CRUD + Destination 管理方法
|
||
- [x] ClusterStore<TContext> 实现已创建,支持软删除
|
||
- [x] 旧的 IInstanceStore/InstanceStore 已删除(被 IClusterStore 替代)
|
||
- [x] 构建通过,0 个错误
|
||
|
||
## 计划偏差
|
||
|
||
**1. [规则 2 - 自动添加缺失功能] 修复 DI 注册引用**
|
||
- **发现时机:** 构建验证
|
||
- **问题:** Extensions.cs 和 GatewayExtensions.cs 仍引用已删除的 IInstanceStore
|
||
- **修复:** 更新两个文件以注册 IClusterStore/ClusterStore
|
||
- **修改文件:** Extensions.cs、GatewayExtensions.cs
|
||
|
||
**2. [规则 1 - 自动修复 Bug] 修复 EF Core OwnsMany 配置**
|
||
- **发现时机:** 构建验证
|
||
- **问题:** PlatformDbContext 中 OwnsMany 构建器使用不正确
|
||
- **修复:** 更正配置以使用正确的 OwnedMany 模式,包含外键的影子属性
|
||
- **修改文件:** PlatformDbContext.cs
|
||
|
||
## 认证门槛
|
||
|
||
无。
|
||
|
||
## 备注
|
||
|
||
基础设施层现已准备好进入下一阶段:
|
||
- GwCluster 聚合已在 DbContext 中正确配置
|
||
- IClusterStore 遵循已建立的 Manager + Store 模式
|
||
- 所有已废弃的 IInstanceStore 引用已被移除
|
||
- DI 注册已在 Extensions.cs 和 GatewayExtensions.cs 中更新 |