Skip to content

Commit

Permalink
feature: 高性能Polaris网关项目-环境搭建-第06节
Browse files Browse the repository at this point in the history
  • Loading branch information
binghe001 committed Sep 24, 2024
1 parent 86f19f1 commit ee1b163
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@
* [《高性能Polaris网关》通用模型-第03节:响应模型的顶层接口实现类设计](https://articles.zsxq.com/id_nqfqr3vpe3ri.html)
* [《高性能Polaris网关》通用模型-第04节:调用链路顶层接口与抽象类设计](https://articles.zsxq.com/id_tfnwsj54urvg.html)
* [《高性能Polaris网关》通用模型-第05节:调用链路顶层接口的实现类设计](https://articles.zsxq.com/id_s6ddb045x0uk.html)
* [《高性能Polaris网关》通用模型-第06节:网关配置规则模型实现类设计](https://articles.zsxq.com/id_fnpiq7jtk9oj.html)

### 💥 分布式IM即时通讯系统

Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,7 @@ function getBarGateway(){
"model/2024-09-18-chapter03.md",
"model/2024-09-22-chapter04.md",
"model/2024-09-23-chapter05.md",
"model/2024-09-24-chapter06.md",
]
}
]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/md/all/all.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ title: 冰河指南
* [《高性能Polaris网关》通用模型-第03节:响应模型的顶层接口实现类设计](https://articles.zsxq.com/id_nqfqr3vpe3ri.html)
* [《高性能Polaris网关》通用模型-第04节:调用链路顶层接口与抽象类设计](https://articles.zsxq.com/id_tfnwsj54urvg.html)
* [《高性能Polaris网关》通用模型-第05节:调用链路顶层接口的实现类设计](https://articles.zsxq.com/id_s6ddb045x0uk.html)
* [《高性能Polaris网关》通用模型-第06节:网关配置规则模型实现类设计](https://articles.zsxq.com/id_fnpiq7jtk9oj.html)

### 💥 分布式IM即时通讯系统

Expand Down
1 change: 1 addition & 0 deletions docs/md/other/guide-to-reading.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ title: 冰河指南
* [《高性能Polaris网关》通用模型-第03节:响应模型的顶层接口实现类设计](https://articles.zsxq.com/id_nqfqr3vpe3ri.html)
* [《高性能Polaris网关》通用模型-第04节:调用链路顶层接口与抽象类设计](https://articles.zsxq.com/id_tfnwsj54urvg.html)
* [《高性能Polaris网关》通用模型-第05节:调用链路顶层接口的实现类设计](https://articles.zsxq.com/id_s6ddb045x0uk.html)
* [《高性能Polaris网关》通用模型-第06节:网关配置规则模型实现类设计](https://articles.zsxq.com/id_fnpiq7jtk9oj.html)

### 💥 分布式IM即时通讯系统

Expand Down
61 changes: 61 additions & 0 deletions docs/md/project/gateway/model/2024-09-24-chapter06.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: 第06节:网关配置规则模型实现类设计
pay: https://articles.zsxq.com/id_fnpiq7jtk9oj.html
---

# 《高性能Polaris网关》通用模型-第06节:网关配置规则模型实现类设计

作者:冰河
<br/>星球:[http://m6z.cn/6aeFbs](http://m6z.cn/6aeFbs)
<br/>博客:[https://binghe.gitcode.host](https://binghe.gitcode.host)
<br/>文章汇总:[https://binghe.gitcode.host/md/all/all.html](https://binghe.gitcode.host/md/all/all.html)
<br/>源码获取地址:[https://t.zsxq.com/0dhvFs5oR](https://t.zsxq.com/0dhvFs5oR)

> 沉淀,成长,突破,帮助他人,成就自我。
* 本章难度:★★☆☆☆
* 本节重点:对高性能Polaris网关的配置规则模型实现类进行设计,从全局角度掌握高性能Polaris网关配置规则的设计。重点掌握整体调用链路的设计思路和设计方法,并能够将其灵活应用到自身实际项目中。

**大家好,我是冰河~~**

网关的规则是可配置的,也就是说,最终我们自己手写的网关规则是可通过配置中心进行配置和管理的,并且在配置中心修改对应的规则后,程序会立即生效。所以,需要对高性能Polaris网关的配置规则模型类进行设计,以便满足网关的可视化配置需求。

## 一、前言

在前面的章节中,已经对高性能Polaris网关的请求与响应模型的顶层接口进行了设计,对请求模型和响应模型的顶层接口进行了实现,对调用链路的顶层接口与抽象类进行了设计,并且对调用链路的顶层接口实现类进行了设计。接下来,我们就对网关配置模型的实现类进行设计。

## 二、本节诉求

对高性能Polaris网关的配置规则模型实现类进行设计,从全局角度掌握高性能Polaris网关配置规则的设计。重点掌握整体调用链路的设计思路和设计方法,并能够将其灵活应用到自身实际项目中。

## 三、规则模型类设计

网关配置规则模型实现类设计如图6-1所示。

<div align="center">
<img src="https://binghe.gitcode.host/images/project/gateway/2024-09-24-001.png?raw=true" width="70%">
<br/>
</div>

可以看到,在设计网关的配置类时,我们将其抽象出FilterRule和Rule两个类。

* FilterRule:网关过滤规则,主要是针对网关接口级别、实例级别、服务级别的过滤规则,提供两个核心字段,一个是id,一个是config。
* id:过滤规则id,唯一标识过滤规则。
* config:过滤规则配置项内容,json格式的具体配置内容。
* Rule:Rule类是网关规则配置类,封装网关的核心配置规则,后续会将Rule类封装的数据配置到配置中心,主要包含如下核心字段:
* id:规则配置id,唯一标识规则配置。
* name: 规则的名称,自定义的名称。
* protocol:规则的协议,例如:http、rpc、websocket等。
* serviceId:后端服务的id。
* prefix:请求的path前缀,例如/api/user/*
* paths:接口的集合。
* order:排序的规则,网关会根据order进行排序,按先后顺序执行规则。
* filterRules:网关过滤规则列表。

## 四、编码实现

接下来,就对网关配置规则模型实现类进行编码实现。

## 查看完整文章

加入[冰河技术](https://public.zsxq.com/groups/48848484411888.html)知识星球,解锁完整技术文章、小册、视频与完整代码

0 comments on commit ee1b163

Please sign in to comment.