fengling-platform/.planning/phases/03-/03-gateway-cluster-entities-PLAN.md

5.8 KiB
Raw Permalink Blame History

phase plan type wave depends_on files_modified autonomous requirements must_haves
03- 01 execute 1
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
true
GATEWAY-RESTRUCTURE-01
GATEWAY-RESTRUCTURE-02
truths artifacts
GwCluster 使用 string Id (GUID)
GwDestination 作为 Owned Entity 内嵌
值对象使用 Owned Entity 配置
path provides min_lines
Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwCluster.cs 集群聚合根 50
path provides min_lines
Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwDestination.cs 目标端点值对象 30
path provides min_lines
Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwHealthCheckConfig.cs 健康检查配置值对象 20
path provides min_lines
Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwSessionAffinityConfig.cs 会话亲和配置值对象 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; }

/// <summary>
/// 健康检查路径
/// </summary>
public string? Path { get; set; }

/// <summary>
/// 检查间隔(秒)
/// </summary>
public int IntervalSeconds { get; set; } = 30;

/// <summary>
/// 超时时间(秒)
/// </summary>
public int TimeoutSeconds { get; set; } = 10;

}

  </action>
  <verify>文件可编译</verify>
  <done>GwHealthCheckConfig 值对象已创建</done>
</task>

<task type="auto">
  <name>任务 2: 创建 GwSessionAffinityConfig 值对象</name>
  <files>Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwSessionAffinityConfig.cs</files>
  <action>
创建会话亲和配置值对象:
```csharp
namespace Fengling.Platform.Domain.AggregatesModel.GatewayAggregate;

/// <summary>
/// 会话亲和配置(值对象)
/// </summary>
public class GwSessionAffinityConfig
{
    /// <summary>
    /// 是否启用会话亲和
    /// </summary>
    public bool Enabled { get; set; }
    
    /// <summary>
    /// 策略Header, Cookie
    /// </summary>
    public string Policy { get; set; } = "Header";
    
    /// <summary>
    /// 亲和键名称
    /// </summary>
    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;

/// <summary>
/// 后端地址
/// </summary>
public string Address { get; set; } = string.Empty;

/// <summary>
/// 健康检查端点
/// </summary>
public string? Health { get; set; }

/// <summary>
/// 权重(用于加权负载均衡)
/// </summary>
public int Weight { get; set; } = 1;

/// <summary>
/// 健康状态
/// </summary>
public int HealthStatus { get; set; } = 1;

/// <summary>
/// 状态
/// </summary>
public int Status { get; set; } = 1;

}

  </action>
  <verify>文件可编译</verify>
  <done>GwDestination 值对象已创建</done>
</task>

<task type="auto">
  <name>任务 4: 创建 GwCluster 聚合根</name>
  <files>Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwCluster.cs</files>
  <action>
创建 GwCluster 聚合根:
- Id: string (GUID)
- ClusterId: string (业务标识)
- Name: string
- Description: string?
- Destinations: List&lt;GwDestination&gt; (内嵌)
- LoadBalancingPolicy: string
- HealthCheck: GwHealthCheckConfig?
- SessionAffinity: GwSessionAffinityConfig?
- Status: int
- 审计字段

参考现有 GwTenantRoute 的结构风格。
  </action>
  <verify>dotnet build Fengling.Platform.Domain 通过</verify>
  <done>GwCluster 聚合根已创建,包含所有字段</done>
</task>

## 验证

- [ ] 所有 4 个文件已创建
- [ ] Build 无错误通过
- [ ] 值对象结构符合 YARP 配置模型

## 成功标准

Domain 实体准备好进行 Infrastructure 层更新。