4.4 KiB
4.4 KiB
Gateway 实体变更记录
变更日期: 2026-03-04 Platform 版本: 1.0.12
变更概述
Platform 1.0.12 对 Gateway 相关实体进行了重构,主要变化是将实例(Instance)内嵌到集群(Cluster)中,简化了领域模型。
实体变更
1. GwDestination(新增 - 原 GatewayInstance)
旧名称: GatewayInstance 新名称: GwDestination 类型: 值对象(内嵌于 GwCluster)
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(新增)
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 需要进行以下适配:
-
移除 IInstanceStore 依赖
- 移除
IInstanceStore注入 - 使用
IClusterStore替代
- 移除
-
更新 GatewayService
- 实例操作改为通过
IClusterStore.AddDestinationAsync等方法 - 查询实例改为从
GwCluster.Destinations获取
- 实例操作改为通过
-
更新数据模型
- GatewayInstanceDto → 从 GwDestination 映射
- GatewayClusterDto → 从 GwCluster 映射
-
更新 API 端点
/instances相关端点可能需要调整
相关文件
Platform 侧
Fengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwCluster.csFengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwDestination.csFengling.Platform.Domain/AggregatesModel/GatewayAggregate/GwTenantRoute.csFengling.Platform.Infrastructure/IClusterStore.csFengling.Platform.Infrastructure/ClusterStore.cs
Console 侧(需要适配)
src/Services/GatewayService.cs- 需要适配新接口src/Program.cs- 需要更新依赖注入