From ddff866cb7151bea021567173557c90e8f54d9da Mon Sep 17 00:00:00 2001 From: token <239573049@qq.com> Date: Sat, 27 Jan 2024 01:26:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B7=AF=E7=94=B1=E6=8E=88?= =?UTF-8?q?=E6=9D=83=20=E5=A2=9E=E5=8A=A0=E9=9B=86=E7=BE=A4Health?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Gateway/Entities/ClusterEntity.cs | 6 ++++++ src/Gateway/Services/GatewayService.cs | 13 ++++++------ web/src/components/Cluster-Gateway.tsx | 20 ++++++++++++------ web/src/components/Create-Cluster.tsx | 9 ++++++++- web/src/components/Create-Router.tsx | 6 +++++- web/src/components/Router-Gateway.tsx | 28 +++++++++++++++++++++++++- web/src/components/Update-Cluster.tsx | 8 ++++++++ web/src/components/Update-Route.tsx | 6 +++++- web/src/index.d.ts | 4 ++++ 9 files changed, 84 insertions(+), 16 deletions(-) diff --git a/src/Gateway/Entities/ClusterEntity.cs b/src/Gateway/Entities/ClusterEntity.cs index 1e139fb..3cdabde 100644 --- a/src/Gateway/Entities/ClusterEntity.cs +++ b/src/Gateway/Entities/ClusterEntity.cs @@ -14,6 +14,7 @@ public sealed class ClusterEntity : Entity /// 集群描述 /// public string? Description { get; set; } + [Column(MapType = typeof(string), StringLength = -1)] public List DestinationsEntities { get; set; } = new(); @@ -26,4 +27,9 @@ public sealed class DestinationsEntity public string Address { get; set; } public string? Host { get; set; } + + /// + /// 接受活动运行状况检查探测的端点。例如 http://127.0.0.1:1234 。 + /// + public string? Health { get; set; } } \ No newline at end of file diff --git a/src/Gateway/Services/GatewayService.cs b/src/Gateway/Services/GatewayService.cs index a567de9..0fe7853 100644 --- a/src/Gateway/Services/GatewayService.cs +++ b/src/Gateway/Services/GatewayService.cs @@ -36,8 +36,9 @@ public class GatewayService( foreach (var cluster in from item in clusters let items = item.DestinationsEntities.ToDictionary(entity => entity.Id, - entity => new DestinationConfig() { Address = entity.Address, Host = entity.Host, }) - select new ClusterConfig() + entity => new DestinationConfig + { Address = entity.Address, Host = entity.Host, Health = entity.Health }) + select new ClusterConfig { ClusterId = item.ClusterId, Destinations = items @@ -137,7 +138,7 @@ public class GatewayService( entity.MaxRequestBodySize = routeEntity.MaxRequestBodySize; entity.Path = routeEntity.Path; entity.Hosts = routeEntity.Hosts; - + await freeSql.Update().SetSource(entity).ExecuteAffrowsAsync(); return ResultDto.Success(); @@ -224,16 +225,16 @@ public class GatewayService( { var entity = await freeSql.Select().Where(x => x.ClusterId == clusterEntity.ClusterId) .FirstAsync(); - + if (entity == null) { return ResultDto.Error("集群Id不存在"); } - + entity.ClusterName = clusterEntity.ClusterName; entity.Description = clusterEntity.Description; entity.DestinationsEntities = clusterEntity.DestinationsEntities; - + await freeSql.Update().SetSource(entity).ExecuteAffrowsAsync(); return ResultDto.Success(); diff --git a/web/src/components/Cluster-Gateway.tsx b/web/src/components/Cluster-Gateway.tsx index 2b093e8..23ac0c1 100644 --- a/web/src/components/Cluster-Gateway.tsx +++ b/web/src/components/Cluster-Gateway.tsx @@ -65,7 +65,6 @@ export default function ClusterGateway({ activeKey }: IProps) { header={item.clusterName} itemKey={item.clusterId}> <> -
{item.description}
- 集群地址: - {item.destinationsEntities.map((x: DestinationsEntity) => { - return ({x.address}) +
集群列表
+ {item.destinationsEntities.map((x: DestinationsEntity, i: number) => { + return (
+ 集群地址:{x.address} + 集群health:{x.health} +
) })}
diff --git a/web/src/components/Create-Cluster.tsx b/web/src/components/Create-Cluster.tsx index 5d16d4a..af4995c 100644 --- a/web/src/components/Create-Cluster.tsx +++ b/web/src/components/Create-Cluster.tsx @@ -38,7 +38,7 @@ export default function CreateCluster({ visible, onCancel, onSusccess }: IProps) } return ( - +
+ +