mirror of
https://github.com/239573049/FastGateway.git
synced 2026-10-17 05:20:30 +08:00
增加路由授权
增加集群Health
This commit is contained in:
@@ -14,6 +14,7 @@ public sealed class ClusterEntity : Entity
|
||||
/// 集群描述
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
|
||||
[Column(MapType = typeof(string), StringLength = -1)]
|
||||
public List<DestinationsEntity> DestinationsEntities { get; set; } = new();
|
||||
@@ -26,4 +27,9 @@ public sealed class DestinationsEntity
|
||||
public string Address { get; set; }
|
||||
|
||||
public string? Host { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接受活动运行状况检查探测的端点。例如<c> http://127.0.0.1:1234 </c>。
|
||||
/// </summary>
|
||||
public string? Health { get; set; }
|
||||
}
|
||||
@@ -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<RouteEntity>().SetSource(entity).ExecuteAffrowsAsync();
|
||||
|
||||
return ResultDto.Success();
|
||||
@@ -224,16 +225,16 @@ public class GatewayService(
|
||||
{
|
||||
var entity = await freeSql.Select<ClusterEntity>().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<ClusterEntity>().SetSource(entity).ExecuteAffrowsAsync();
|
||||
|
||||
return ResultDto.Success();
|
||||
|
||||
@@ -65,7 +65,6 @@ export default function ClusterGateway({ activeKey }: IProps) {
|
||||
header={item.clusterName}
|
||||
itemKey={item.clusterId}>
|
||||
<>
|
||||
|
||||
<div style={{
|
||||
float: 'left',
|
||||
marginBottom: '20px',
|
||||
@@ -79,11 +78,20 @@ export default function ClusterGateway({ activeKey }: IProps) {
|
||||
<span>{item.description}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>集群地址:</span>
|
||||
<span>{item.destinationsEntities.map((x: DestinationsEntity) => {
|
||||
return (<Tag style={{
|
||||
marginRight: '5px',
|
||||
}} size="small" shape='circle' color='amber'>{x.address}</Tag>)
|
||||
<div style={{
|
||||
marginTop: '5px',
|
||||
fontWeight: 'bold',
|
||||
fontSize: '18px',
|
||||
}}>集群列表</div>
|
||||
<span>{item.destinationsEntities.map((x: DestinationsEntity, i: number) => {
|
||||
return (<div key={i}>
|
||||
集群地址:<Tag style={{
|
||||
marginRight: '5px',
|
||||
}} size="small" shape='circle' color='amber'>{x.address}</Tag>
|
||||
集群health:<Tag style={{
|
||||
marginRight: '5px',
|
||||
}} size="small" shape='circle' color='amber'>{x.health}</Tag>
|
||||
</div>)
|
||||
})}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function CreateCluster({ visible, onCancel, onSusccess }: IProps)
|
||||
}
|
||||
|
||||
return (
|
||||
<SideSheet width={500} title="创建集群" visible={visible} onCancel={onCancel}>
|
||||
<SideSheet width={650} title="创建集群" visible={visible} onCancel={onCancel}>
|
||||
<Form style={{
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'auto',
|
||||
@@ -76,6 +76,13 @@ export default function CreateCluster({ visible, onCancel, onSusccess }: IProps)
|
||||
style={{ width: 170, marginRight: 16 }}
|
||||
>
|
||||
</Input>
|
||||
<Input
|
||||
field={`${field}[health]`}
|
||||
size='large'
|
||||
label={`状况检查探测的端点`}
|
||||
style={{ width: 200, marginRight: 16 }}
|
||||
>
|
||||
</Input>
|
||||
<Button
|
||||
type='danger'
|
||||
theme='borderless'
|
||||
|
||||
@@ -11,7 +11,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
const { Option } = Form.Select;
|
||||
const { Select, Input, TagInput } = Form;
|
||||
const { Select, Input, TagInput, Checkbox } = Form;
|
||||
|
||||
export default function CreateRouter({ visible, onCancel, onSusccess }: IProps) {
|
||||
const [clusterIds, setClusterIds] = useState<ClusterEntity[]>([]);
|
||||
@@ -59,6 +59,10 @@ export default function CreateRouter({ visible, onCancel, onSusccess }: IProps)
|
||||
{ validator: (rule, value) => value.length < 10, message: '路由名称长度不能超过10位' },
|
||||
]} field='routeName' required={true} size='large' label='路由名称' style={{ width: '100%' }} placeholder='请输入路由名称'></Input>
|
||||
<Input field='description' label='路由描述' size='large' style={{ width: '100%' }} placeholder='请输入路由描述'></Input>
|
||||
<Input field='authorizationPolicy' label='授权策略' size='large' style={{ width: '100%' }} placeholder='请输入授权策略'></Input>
|
||||
<Checkbox field='requireHttpsMetadata' label='认证中心是否需要https' style={{ width: '100%' }}></Checkbox>
|
||||
<Input field='authorizationPolicyAddress' placeholder='请输入授权认证中心地址' size='large' label='授权认证中心地址' style={{ width: '100%' }}></Input>
|
||||
<Input field='maxRequestBodySize' min={16777216} max={999999999} placeholder='请输入请求Body最大长度' type='number' size='large' label='请求Body最大长度' style={{ width: '100%' }}></Input>
|
||||
<Select field='clusterId' rules={[
|
||||
{
|
||||
required: true,
|
||||
|
||||
@@ -35,7 +35,7 @@ export default function RouterGateway({ activeKey }: IProps) {
|
||||
}, [
|
||||
activeKey
|
||||
]);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<List
|
||||
@@ -105,6 +105,32 @@ export default function RouterGateway({ activeKey }: IProps) {
|
||||
</Tag>)
|
||||
})}</span>
|
||||
</div>
|
||||
<div style={{
|
||||
marginTop: '5px',
|
||||
}}>
|
||||
<span>授权策略:</span>
|
||||
<span>{item.authorizationPolicy}</span>
|
||||
</div>
|
||||
<div style={{
|
||||
marginTop: '5px',
|
||||
}}>
|
||||
<span>授权认证中心地址:</span>
|
||||
<span>{item.authorizationPolicyAddress}</span>
|
||||
</div>
|
||||
<div style={{
|
||||
marginTop: '5px',
|
||||
}}>
|
||||
<span>认证中心是否需要https:</span>
|
||||
<span>{item.requireHttpsMetadata ? '是' : '否'}</span>
|
||||
</div>
|
||||
|
||||
<div style={{
|
||||
marginTop: '5px',
|
||||
}}>
|
||||
<span>请求Body最大长度:</span>
|
||||
<span>{item.maxRequestBodySize}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style={{
|
||||
float: 'right',
|
||||
|
||||
@@ -85,6 +85,14 @@ export default function UpdateCluster({ visible, onCancel, onSusccess, cluster }
|
||||
style={{ width: 170, marginRight: 16 }}
|
||||
>
|
||||
</Input>
|
||||
<Input
|
||||
field={`${field}[health]`}
|
||||
size='large'
|
||||
initValue={cluster?.destinationsEntities[i]?.health}
|
||||
label={`状况检查探测的端点`}
|
||||
style={{ width: 200, marginRight: 16 }}
|
||||
>
|
||||
</Input>
|
||||
<Button
|
||||
type='danger'
|
||||
theme='borderless'
|
||||
|
||||
@@ -11,7 +11,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
const { Option } = Form.Select;
|
||||
const { Select, Input, TagInput } = Form;
|
||||
const { Select, Input, TagInput, Checkbox } = Form;
|
||||
|
||||
|
||||
export default function UpdateCluster({ visible, onCancel, onSusccess, router }: IProps) {
|
||||
@@ -63,6 +63,10 @@ export default function UpdateCluster({ visible, onCancel, onSusccess, router }:
|
||||
{ validator: (rule, value) => value.length < 10, message: '路由名称长度不能超过10位' },
|
||||
]} field='routeName' required={true} size='large' label='路由名称' style={{ width: '100%' }} placeholder='请输入路由名称'></Input>
|
||||
<Input initValue={router?.description} field='description' label='路由描述' size='large' style={{ width: '100%' }} placeholder='请输入路由描述'></Input>
|
||||
<Input field='authorizationPolicy' initValue={router?.authorizationPolicy} label='授权策略' size='large' style={{ width: '100%' }} placeholder='请输入授权策略'></Input>
|
||||
<Checkbox field='requireHttpsMetadata' initValue={router?.requireHttpsMetadata} label='认证中心是否需要https' style={{ width: '100%' }}></Checkbox>
|
||||
<Input field='authorizationPolicyAddress' initValue={router?.authorizationPolicyAddress} placeholder='请输入授权认证中心地址' size='large' label='授权认证中心地址' style={{ width: '100%' }}></Input>
|
||||
<Input field='maxRequestBodySize' min={16777216} initValue={router?.maxRequestBodySize} placeholder='请输入请求Body最大长度' type='number' size='large' label='请求Body最大长度' style={{ width: '100%' }}></Input>
|
||||
<Select initValue={router?.clusterId} field='clusterId' rules={[
|
||||
{
|
||||
required: true,
|
||||
|
||||
Vendored
+4
@@ -4,6 +4,9 @@ export interface RouteEntity {
|
||||
description: string;
|
||||
clusterId: string | null;
|
||||
maxRequestBodySize: number | null;
|
||||
authorizationPolicy:string | null;
|
||||
requireHttpsMetadata:boolean | null;
|
||||
authorizationPolicyAddress:string | null;
|
||||
path: string;
|
||||
hosts: string[];
|
||||
clusterEntity: ClusterEntity | null;
|
||||
@@ -19,6 +22,7 @@ export interface ClusterEntity {
|
||||
export interface DestinationsEntity {
|
||||
id: string;
|
||||
address: string;
|
||||
health:string | null;
|
||||
host: string | null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user