docs(phase-4): add plan for Platform 1.0.12 entity adaptation

This commit is contained in:
movingsam 2026-03-04 10:24:48 +08:00
parent e05e10df95
commit da1048c3ae
4 changed files with 314 additions and 4 deletions

View File

@ -66,3 +66,28 @@
#### Plans #### Plans
- [x] 03-PLAN.md — 实施计划 - [x] 03-PLAN.md — 实施计划
---
### Phase 4: 适配 Platform 1.0.12 Gateway 实体变更
- **目标**: 适配 Platform 1.0.12 中的 Gateway 实体重构,修复编译错误,更新 Console 代码以使用新的 GwCluster/GwDestination/GwTenantRoute 模型
WR|- [x] 04-PLAN.md — 实施计划
NH|- **状态**: Planned
#### Goal
适配 Platform 1.0.12 实体变更:
- 移除 IInstanceStore 依赖,改用 IClusterStore
- 更新 GatewayService 使用新的接口方法
- 更新数据模型映射GatewayInstanceDto → GwDestination
- 修复编译错误
#### Depends on
- Phase 3: 网关配置变更广播机制
#### Plans
- [ ] 04-PLAN.md — 实施计划

View File

@ -1,6 +1,6 @@
# 状态Fengling Console # 状态Fengling Console
**最后更新:** 2026-03-03 **最后更新:** 2026-03-04
--- ---
@ -10,7 +10,7 @@
**核心价值:** 统一的管理入口,负责所有运维相关的配置和操作,让其他服务专注于业务逻辑。 **核心价值:** 统一的管理入口,负责所有运维相关的配置和操作,让其他服务专注于业务逻辑。
**当前重点:** Phase 3: 上下文已捕获 **当前重点:** Phase 4: 待添加(适配 Platform 1.0.12 实体变更)
--- ---
@ -21,6 +21,7 @@
| PROJECT.md | ✓ 已初始化 | | PROJECT.md | ✓ 已初始化 |
| CODEBASE | ✓ 已有ARCHITECTURE.md, CONCERNS.md, STACK.md 等) | | CODEBASE | ✓ 已有ARCHITECTURE.md, CONCERNS.md, STACK.md 等) |
| Roadmap | ✓ 已创建 | | Roadmap | ✓ 已创建 |
| 变更文档 | ✓ 已创建 |
--- ---
@ -39,6 +40,7 @@
- **2026-03-03** Phase 3 已添加:网关配置变更广播机制 - **2026-03-03** Phase 3 已添加:网关配置变更广播机制
- **2026-03-03** Phase 3 已规划 - **2026-03-03** Phase 3 已规划
- **2026-03-03** Phase 3 上下文已捕获:广播策略 = 仅手动触发 - **2026-03-03** Phase 3 上下文已捕获:广播策略 = 仅手动触发
- **2026-03-04** Platform 1.0.12 实体变更Gateway → GwCluster/GwDestination/GwTenantRoute
### 与 Gateway 的集成 ### 与 Gateway 的集成
@ -52,7 +54,21 @@
### 待完成任务 ### 待完成任务
- 无 - **适配 Platform 1.0.12 实体变更**(编译错误待修复)
---
## 变更记录
### Platform 1.0.12 Gateway 实体变更
详细变更见:`.planning/docs/gateway-entity-changes-1.0.12.md`
**主要变更:**
1. GatewayInstance → GwDestination内嵌值对象
2. GatewayCluster → GwCluster聚合根包含 Destinations
3. GatewayRoute → GwTenantRoute通过 ClusterId 关联)
4. IInstanceStore 移除,改用 IClusterStore
--- ---
@ -64,4 +80,4 @@
--- ---
*最后更新2026-03-03* *最后更新2026-03-04*

View File

@ -0,0 +1,141 @@
# Gateway 实体变更记录
**变更日期:** 2026-03-04
**Platform 版本:** 1.0.12
---
## 变更概述
Platform 1.0.12 对 Gateway 相关实体进行了重构,主要变化是将实例(Instance)内嵌到集群(Cluster)中,简化了领域模型。
---
## 实体变更
### 1. GwDestination新增 - 原 GatewayInstance
**旧名称:** GatewayInstance
**新名称:** GwDestination
**类型:** 值对象(内嵌于 GwCluster
```csharp
public class GwDestination
{
public string DestinationId { get; set; } // 目标标识
public string Address { get; set; } // 后端地址
public string? Health { get; set; } // 健康检查端点
public int Weight { get; set; } = 1; // 权重
public int HealthStatus { get; set; } = 1; // 健康状态
public int Status { get; set; } = 1; // 状态
}
```
### 2. GwCluster重构 - 原 GatewayCluster
**旧名称:** GatewayCluster
**新名称:** GwCluster
**类型:** 聚合根
**主要变化:**
- 包含 `List<GwDestination> Destinations` 作为内嵌集合
- 包含 `GwLoadBalancingPolicy` 负载均衡策略
- 包含 `GwHealthCheckConfig` 健康检查配置
- 包含 `GwSessionAffinityConfig` 会话亲和配置
### 3. GwTenantRoute重构 - 原 GatewayRoute
**旧名称:** GatewayRoute
**新名称:** GwTenantRoute
**类型:** 实体
**主要变化:**
- 通过 `ClusterId` 关联到 `GwCluster`
- 包含 `GwRouteMatch` 路由匹配配置
- 支持 `GwLoadBalancingPolicy` 路由级别负载均衡覆盖
---
## 接口变更
### IInstanceStore已移除
**状态:** 已移除
**原因:** 实例(Destination)现在是 GwCluster 的内嵌对象,不再需要独立的 IInstanceStore 接口。
### IClusterStore新增
```csharp
public interface IClusterStore
{
// Basic CRUD
Task<GwCluster?> FindByIdAsync(string? id, CancellationToken cancellationToken = default);
Task<GwCluster?> FindByClusterIdAsync(string clusterId, CancellationToken cancellationToken = default);
Task<IList<GwCluster>> GetAllAsync(CancellationToken cancellationToken = default);
Task<IList<GwCluster>> GetPagedAsync(int page, int pageSize, string? clusterId = null,
string? name = null, int? status = null, CancellationToken cancellationToken = default);
Task<int> GetCountAsync(string? clusterId = null, string? name = null,
int? status = null, CancellationToken cancellationToken = default);
Task<IdentityResult> CreateAsync(GwCluster cluster, CancellationToken cancellationToken = default);
Task<IdentityResult> UpdateAsync(GwCluster cluster, CancellationToken cancellationToken = default);
Task<IdentityResult> DeleteAsync(GwCluster cluster, CancellationToken cancellationToken = default);
// Destination management (NEW)
Task<GwCluster?> AddDestinationAsync(string clusterId, GwDestination destination, CancellationToken cancellationToken = default);
Task<GwCluster?> UpdateDestinationAsync(string clusterId, string destinationId, GwDestination destination, CancellationToken cancellationToken = default);
Task<GwCluster?> RemoveDestinationAsync(string clusterId, string destinationId, CancellationToken cancellationToken = default);
}
```
---
## 架构变化
### 旧架构
```
Route → ClusterId → Instance (独立实体)
```
### 新架构
```
TenantRoute → ClusterId → GwCluster (聚合根) → List<GwDestination>
```
---
## Console 适配需求
由于接口变更Console 需要进行以下适配:
1. **移除 IInstanceStore 依赖**
- 移除 `IInstanceStore` 注入
- 使用 `IClusterStore` 替代
2. **更新 GatewayService**
- 实例操作改为通过 `IClusterStore.AddDestinationAsync` 等方法
- 查询实例改为从 `GwCluster.Destinations` 获取
3. **更新数据模型**
- GatewayInstanceDto → 从 GwDestination 映射
- GatewayClusterDto → 从 GwCluster 映射
4. **更新 API 端点**
- `/instances` 相关端点可能需要调整
---
## 相关文件
### Platform 侧
- `Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwCluster.cs`
- `Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwDestination.cs`
- `Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwTenantRoute.cs`
- `Fengling.Platform.Infrastructure/IClusterStore.cs`
- `Fengling.Platform.Infrastructure/ClusterStore.cs`
### Console 侧(需要适配)
- `src/Services/GatewayService.cs` - 需要适配新接口
- `src/Program.cs` - 需要更新依赖注入

View File

@ -0,0 +1,128 @@
---
phase: 04-gateway-entity-update
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
- src/Services/GatewayService.cs
- src/Program.cs
autonomous: true
requirements: []
user_setup: []
must_haves:
truths:
- "编译错误已修复"
- "GatewayService 使用新的 IClusterStore 接口"
- "实例操作改为通过 Cluster.Destinations 管理"
artifacts:
- path: "src/Services/GatewayService.cs"
provides: "GatewayService 使用 IClusterStore"
- path: "src/Program.cs"
provides: "依赖注入更新"
key_links:
- from: "GatewayService"
to: "IClusterStore"
via: "依赖注入"
---
<objective>
适配 Platform 1.0.12 中的 Gateway 实体重构,修复编译错误,更新 Console 代码以使用新的 GwCluster/GwDestination/GwTenantRoute 模型。
</objective>
<context>
@.planning/docs/gateway-entity-changes-1.0.12.md
## 编译错误
当前编译错误:
```
error CS0246: IInstanceStore 找不到
```
## 变更摘要
1. **IInstanceStore 已移除** - 实例现在是 GwCluster 的内嵌对象
2. **IClusterStore 是新接口** - 包含 Destination 管理方法
3. **数据模型变化**:
- GatewayInstance → GwDestination内嵌值对象
- GatewayCluster → GwCluster聚合根包含 Destinations
- 路由通过 ClusterId 关联到集群
</context>
<tasks>
<task type="auto">
<name>任务 1: 更新 Program.cs 依赖注入</name>
<files>src/Program.cs</files>
<action>
1. 移除 IInstanceStore 的注入(如果有)
2. 添加 IClusterStore 的注入:
```csharp
builder.Services.AddScoped<IClusterStore, ClusterStore<PlatformDbContext>>();
```
3. 确保使用正确的 PlatformDbContext
</action>
<verify>
<automated>dotnet build --no-restore 2>&1 | head -30</automated>
</verify>
<done>Program.cs 依赖注入已更新</done>
</task>
<task type="auto">
<name>任务 2: 更新 GatewayService 使用 IClusterStore</name>
<files>src/Services/GatewayService.cs</files>
<action>
1. 移除 IInstanceStore 依赖
2. 添加 IClusterStore 依赖注入
3. 更新实例相关方法:
- GetInstancesAsync → 从 Cluster.Destinations 获取
- AddInstanceAsync → 使用 IClusterStore.AddDestinationAsync
- RemoveInstanceAsync → 使用 IClusterStore.RemoveDestinationAsync
- UpdateInstanceWeightAsync → 使用 IClusterStore.UpdateDestinationAsync
4. 更新数据模型映射:
- GatewayInstanceDto → 从 GwDestination 映射
- GatewayClusterDto → 从 GwCluster 映射
</action>
<verify>
<automated>dotnet build --no-restore 2>&1 | head -30</automated>
</verify>
<done>GatewayService 已更新为使用 IClusterStore</done>
</task>
<task type="auto">
<name>任务 3: 验证编译通过</name>
<files></files>
<action>
运行完整编译验证:
```bash
dotnet build src/Fengling.Console.csproj
```
确保没有编译错误。
</action>
<verify>
<automated>dotnet build src/Fengling.Console.csproj 2>&1 | tail -10</automated>
</verify>
<done>编译通过,无错误</done>
</task>
</tasks>
<verification>
1. dotnet build 编译通过
2. GatewayService 使用 IClusterStore
3. 实例操作通过 Cluster.Destinations 管理
</verification>
<success_criteria>
- [x] IInstanceStore 依赖已移除
- [x] IClusterStore 已集成
- [x] 编译错误已修复
- [x] GatewayService 功能正常
</success_criteria>
<output>
完成后创建 `.planning/phases/04-gateway-entity-update/04-SUMMARY.md`
</output>