--- phase: 03- plan: 01 type: execute wave: 1 depends_on: [] files_modified: - Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwCluster.cs - Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwDestination.cs - Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwHealthCheckConfig.cs - Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwSessionAffinityConfig.cs autonomous: true requirements: - GATEWAY-RESTRUCTURE-01 - GATEWAY-RESTRUCTURE-02 must_haves: truths: - "GwCluster 使用 string Id (GUID)" - "GwDestination 作为 Owned Entity 内嵌" - "值对象使用 Owned Entity 配置" artifacts: - path: "Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwCluster.cs" provides: "集群聚合根" min_lines: 50 - path: "Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwDestination.cs" provides: "目标端点值对象" min_lines: 30 - path: "Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwHealthCheckConfig.cs" provides: "健康检查配置值对象" min_lines: 20 - path: "Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwSessionAffinityConfig.cs" provides: "会话亲和配置值对象" min_lines: 20 --- # 计划 01: 创建 GwCluster 聚合根和值对象 ## 目标 创建新的 GwCluster 聚合根及相关值对象,替代原有的 GwServiceInstance 实体设计。 **目的:** 将服务实例管理改为集群聚合根模式,内嵌 Destinations 列表,符合 YARP ClusterConfig 结构。 **输出:** GwCluster 聚合根、GwDestination 值对象、GwHealthCheckConfig 值对象、GwSessionAffinityConfig 值对象。 ## 上下文 @.planning/phases/03-/03-CONTEXT.md @.planning/phases/03-/03-RESEARCH.md @Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwTenantRoute.cs (现有实体参考) @Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GatewayEnums.cs (枚举) ## 任务 任务 1: 创建 GwHealthCheckConfig 值对象 Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwHealthCheckConfig.cs 创建健康检查配置值对象: ```csharp namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate; /// /// 健康检查配置(值对象) /// public class GwHealthCheckConfig { /// /// 是否启用健康检查 /// public bool Enabled { get; set; } /// /// 健康检查路径 /// public string? Path { get; set; } /// /// 检查间隔(秒) /// public int IntervalSeconds { get; set; } = 30; /// /// 超时时间(秒) /// public int TimeoutSeconds { get; set; } = 10; } ``` 文件可编译 GwHealthCheckConfig 值对象已创建 任务 2: 创建 GwSessionAffinityConfig 值对象 Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwSessionAffinityConfig.cs 创建会话亲和配置值对象: ```csharp namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate; /// /// 会话亲和配置(值对象) /// public class GwSessionAffinityConfig { /// /// 是否启用会话亲和 /// public bool Enabled { get; set; } /// /// 策略:Header, Cookie /// public string Policy { get; set; } = "Header"; /// /// 亲和键名称 /// public string AffinityKeyName { get; set; } = "X-Session-Key"; } ``` 文件可编译 GwSessionAffinityConfig 值对象已创建 任务 3: 创建 GwDestination 值对象 Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwDestination.cs 创建目标端点值对象: ```csharp namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate; /// /// 目标端点(值对象,内嵌于 GwCluster) /// public class GwDestination { /// /// 目标标识 /// public string DestinationId { get; set; } = string.Empty; /// /// 后端地址 /// public string Address { get; set; } = string.Empty; /// /// 健康检查端点 /// public string? Health { get; set; } /// /// 权重(用于加权负载均衡) /// public int Weight { get; set; } = 1; /// /// 健康状态 /// public int HealthStatus { get; set; } = 1; /// /// 状态 /// public int Status { get; set; } = 1; } ``` 文件可编译 GwDestination 值对象已创建 任务 4: 创建 GwCluster 聚合根 Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwCluster.cs 创建 GwCluster 聚合根: - Id: string (GUID) - ClusterId: string (业务标识) - Name: string - Description: string? - Destinations: List<GwDestination> (内嵌) - LoadBalancingPolicy: string - HealthCheck: GwHealthCheckConfig? - SessionAffinity: GwSessionAffinityConfig? - Status: int - 审计字段 参考现有 GwTenantRoute 的结构风格。 dotnet build Fengling.Platform.Domain 通过 GwCluster 聚合根已创建,包含所有字段 ## 验证 - [ ] 所有 4 个文件已创建 - [ ] Build 无错误通过 - [ ] 值对象结构符合 YARP 配置模型 ## 成功标准 Domain 实体准备好进行 Infrastructure 层更新。