129 lines
3.4 KiB
Markdown
129 lines
3.4 KiB
Markdown
---
|
||
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>
|