英 文 : In this article, all references to Apache ShenYu (Incubating) are in the Apache ShenYu incubator. Apache ShenYu(Incubating) Founder && PPMC 2.4.0 Release Manager: Zhang Yonglun Apache ShenYu(Incubating) PPMC && Apache ShardingSphere PMC
All my friends,
The 2.4.0 release of The ShenYu Gateway is the first release of the ShenYu Gateway after the original Dromara/ Soul Gateway was donated to the Apache Foundation. This release involves a number of new feature additions, changes to project names, package names, and maven dependency coordinates.
What is Apache ShenYu?
Apache ShenYu is developed using Java Reactor programming method, with asynchronous, high-performance, cross-language and other features of the API gateway. In terms of flow control, the elegant Admin console can accurately and dynamically control the flow to meet complex business scenarios. In terms of functionality, it uses plug-in design ideas and supports many common protocols such as HTTP/HTTPS, Dubbo, Spring Cloud, GRPC, Motan, Sofa, Tars, etc. At the same time, the built-in plug-in is very rich in functions, such as fuse, current limiting, authentication, blacklist and whitelist, firewall, monitoring, parameter change and so on plug-ins. The architecture diagram is as follows:
Flow control
The control of the flow is the soul of the gateway, for the flow control, Apache ShenYu designed a selector, rules two concepts, to control the flow.
Selectors and rules are the soul of the Apache ShenYu gateway. Get it right and you can manage any traffic.
A plug-in has multiple selectors, and each selector corresponds to multiple rules. The selector is the first level filter for traffic, and the rule is the final filter.
For a plug-in, we want the traffic to meet the criteria based on our configuration before the plug-in is executed.
Selectors and rules are designed to allow traffic to perform what we want under certain conditions. This kind of rule should be understood first.
The execution logic of plug-ins, selectors, and rules is as follows: When the traffic enters the Apache ShenYu gateway, it first checks whether the corresponding plug-in exists and whether the plug-in is enabled. It then determines whether the traffic matches the plug-in’s selector.
Then determine whether the traffic matches the rules of the selector. If the request traffic meets the matching conditions, the plug-in will be executed; otherwise, the plug-in will not be executed and the next one will be processed.
This is how Apache ShenYu gateway completes flow control through layers of filtering. The flowchart is as follows:
Traffic filtering
Traffic filtering is the soul of selectors and rules, corresponding to the matching conditions in the selectors and rules. According to different traffic filtering rules, we can deal with all kinds of complex scenarios.
Traffic filtering can retrieve data from Http requests such as headers, URIs, Queries, cookies, and so on.
Then Match, =, SpEL, Regex, Groovy, etc., to Match the data you expect.
Multiple group matches add matching policies that can use And/Or. Above all is the idea of the design of the SPI, the user is free to extend its own: more see: shenyu.apache.org/zh/projects…
The process diagram is as follows:
Data synchronization and caching
In order to improve the performance of the gateway, Apache ShenYu gateway will cache all the flow control rules in the JVM memory. In the cluster deployment/distributed scenario, Apache ShenYu independently developed a set of scheme to remotely synchronize the data of Admin console to the JVM memory of each Apache ShenYu gateway node.
In each case, SPI design ideas are adopted to provide users with flexible choices. Currently supported solutions are HttpLongPull, Websocket, Zookeeper, Nacos, Consul, ETCD. The overall process is as follows:
The Admin console
In order to facilitate users to quickly and easily control traffic and all features of the gateway,Apache ShenYu
It provides a very elegantThe Admin console
, the user canChinese and English
Up here, you can do whatever you wantControl flow
.Rev. Stop plugin
.Configure different parameters and policies
, these operations are changed through the abovePrinciples of Data Synchronization
, synchronized to the gatewayThe JVM memory
. Its background diagram is as follows:
Menu/data permissions
The background management of gateway is very important. In order to target enterprise-class users and cross-department application agents, Apache ShenYu has designed a complete set of permission control system, which includes button level menu permission and row data level data permission. And these permissions are automatically configurable on the Admin console.
Agent agreement
Protocol proxy is the core function of the gateway. At present, Apache ShenYu supports the conversion of HTTP to HTTP/HTTPS, Websocket,Dubbo, Spring Cloud, GRPC, Motan, Sofa, Tars and other protocols. TCP, MQTT,MQTT and other protocols will be supported in the future.
Divide the plugin
Divide plugin is used to proxy HTTP/HTTPS/Websocket requests to Apache ShenYu gateway plug-in. It has load balancing, traffic preheating, node discovery, timeout retry, timeout control and other functions. If the user wants to use it, add the following dependency on the gateway and set it to turn on in the Admin console -> Plug-in Administration ->Divide plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-divide</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-httpclient</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Dubbo plug-in
The Dubbo plugin is a plugin for ShenYu Gateway to convert HTTP/HTTPS requests to Dubbo. It adopts Dubbo’s generalized invocation mechanism, integrates Dubbo’s client, and has the functions of service discovery, load balancing and so on. The user wants to use it, in the gateway, please add the following dependent, and then in the Admin console — — — — > > plug-in management dubbo plug-in set it to open, the registry and configuration, more details please see: shenyu.apache.org/zh/projects…
<! -- apache shenyu alibaba dubbo plugin start-->
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-alibaba-dubbo</artifactId>
<version>${project.version}</version>
</dependency>
<! -- apache shenyu apache dubbo plugin start-->
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-apache-dubbo</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
SpringCloud plug-in
SpringCloud plug-in is a plug-in for Apache ShenYu gateway agent SpringCloud microservice business. It integrates SpringCloud’s registry with load balancing services and implements a proxy for services. If the user wants to use it, add the following dependency on the gateway and set it to on in the Admin console -> Plug-in Management -> SpringCloud plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-springcloud</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
GRPC plug-in
GRPC is a plug-in for Apache ShenYu Gateway to convert HTTP/HTTPS requests into GRPC. It integrates the GRPC client and implements the proxy of GRPC service. If the user wants to use it, add the following dependency on the gateway and set it to on in the Admin console -> Plug-in Management -> GRPC Plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-grpc</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Tars plug-in
Tars is a plug-in for Apache ShenYu Gateway to convert HTTP/HTTPS requests to Tars. Tars is Tencent’s open source RPC framework. This plug-in integrates Tars-JAVA client and implements Tars service proxy. If the user wants to use it, add the following dependency on the gateway and set it to enabled in the Admin console -> Plug-in Management -> Tars Plug-ins. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-tars</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Sofa plugin
Sofa plug-in is a plug-in for Apache ShenYu Gateway to convert HTTP/HTTPS requests into Sofa-RPC protocol. It adopts the mechanism of Sofa generalization call, integrates the client of Sofa-RPC, and has the functions of service discovery, load balancing, etc. Users who want to use it add the following dependency on the gateway, then set it to on in the Admin console -> Plug-in Management -> SOFA plug-in and configure the registry. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-sofa</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Current limiting fuse
Hystrix plug-in
The Hystrix plugin is an Apache ShenYu gateway integrated with the Hystrix framework. It provides the function of requesting fuse. The Hystrix fuse parameters can be dynamically configured. If you want to use it, add the following dependency on the gateway and set it to on in the Admin console -> Plug-in Management -> Hystrix Plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-hystrix</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Sentinel plug-in
Sentinel plug-in, which integrates Sentinel framework with ShenYu Gateway of Apache, provides the function of requesting fuse current limiting, and the parameters of Sentinel fuse current limiting can be dynamically configured. Users who want to use it should add the following dependency on the gateway and set it to enabled in the Admin console -> Plug-in Management -> Sentinel Plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-sentinel</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Resilience4j plug-in
The Resilience4j plug-in is integrated with the Framework of Apache ShenYu gateway and provides the function of requesting the fuse limit. The Resilience4j fuse limit parameters can be configured dynamically. If you want to use it, add the following dependency on the gateway and set it to enabled on the Admin console –> Plug-in Management –> Resilience4j plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-resilience4j</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
RateLimiter plug-in
RateLimiter is an Apache ShenYu gateway using Redis, provides the request cluster traffic limiting function, traffic limiting algorithm strategy: token bucket algorithm, concurrent traffic limiting, leaky bucket algorithm, sliding window algorithm. If the user wants to use it, add the following dependency on the gateway, then set it to on in the Admin console -> Plug-in Management -> RateLimiter plugin and configure redis. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-ratelimiter</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Security/permission authentication
Waf plug-in
Waf plug-in, is Apache ShenYu gateway, used to implement the firewall traffic, mainly used to intercept illegal requests, or abnormal requests, and give the relevant rejection policy, it provides the function of blacklist and whitelist configuration. If the user wants to use it, add the following dependency on the gateway and set it to enabled in the Admin console -> Plug-in Management -> Waf Plug-ins. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-waf</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Sign the plugin
The Sign plug-in is the Apache ShenYu gateway for signing and authenticating requests. If the user wants to use it, add the following dependency on the gateway and set it to enabled in the Admin console -> Plug-in Management -> Sign plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-sign</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
JWT plug-in
JWT plug-in, the Apache ShenYu gateway, authenticates and determines the token or authorization attributes of HTTP request headers. It is compatible with OAuth2.0. If the user wants to use it, add the following dependency on the gateway and set it to enabled in the Admin console -> Plug-in Management -> JWT Plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-jwt</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
OAuth2 plug-in
The OAuth2 plug-in is the Apache ShenYu gateway, implemented using the Webflux OAuth2 client, and is used to support the OAuth2 protocol. If the user wants to use it, add the following dependency on the gateway and set it to enabled in the Admin console -> Plug-in Management -> OAuth2 plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-oauth2</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Personalization
Rewrite the plugin
Rewrite plugin, the Apache ShenYu gateway, supports the use of regular expressions to Rewrite URIs. If you want to use it, add the following dependencies in the gateway and then turn them on in the Admin console -> Plug-in Management -> rewrite plug-ins. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-rewrite</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Redirect the plugin
Redirect is a plugin for the Apache ShenYu gateway. It supports the internal interface and external address of the gateway. If the user wants to use it, add the following dependency on the gateway and set it to on in the Admin console -> Plug-in Management -> Redirect plug-ins. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-redirect</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Request the plugin
Request plug-in, ShenYu gateway allows users to Request parameters, Request headers and cookies to add, modify, delete and other functions. If the user wants to use it, add the following dependency on the gateway and set it to enabled in the Admin console -> Plug-in Management -> Request plugin. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-request</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
The Context – Path plug-in
Context-path is an Apache ShenYu gateway that allows users to add, modify, and delete context-path in the request Path. If the user wants to use it, add the following dependency on the gateway and set it to on in the Admin console -> Plug-in Management -> Context_path plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-context-path</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Param – Mapping plug-ins
Param-Mapping is an Apache ShenYu gateway that allows users to add, modify, and delete the Body field in the request Body. If the user wants to use it, add the following dependency on the gateway and set it to enable in the Admin console -> Plug-in Management -> param_mapping plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-param-mapping</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
ModifyResponse plug-in
ModifyResponse plug-in, is the Apache ShenYu gateway, used to request response body in the response header, status code, response content, to add, modify, delete and other functions. If the user wants to use it, add the following dependency on the gateway and set it to on in the Admin console -> Plug-in Management -> modifyResponse plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-modify-response</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
observability
The Monitor plugin
Monitor is an Apache ShenYu gateway plug-in that uses Prometheus to Monitor metrics such as request volume, QPS, JVM, etc. Users who want to use it add the following dependency on the gateway, then enable it on the Admin console -> Plug-in Administration -> Monitor plug-in and configure Prometheus parameters. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-monitor</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Logging plug-in
Monitor is an Apache ShenYu gateway. It allows users to print the request information in logs, including the request path, request method, request parameters, response header, and response body. Users who want to use it should add the following dependency on the gateway and then set it to enabled in the Admin console -> Plug-in Management -> Logging plug-in. More details please see: shenyu.apache.org/zh/projects…
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-logging</artifactId>
<version>${project.version}</version>
</dependency>
Copy the code
Plan the next version
-
RPC framework gray release enhancement, including SpringCloud, GRPC, Dubbo, Sofa-RPC, Tars, etc.
-
Add Shenyu-agent module, build gateway metrics, tracing, logging and other observable systems.
-
Custom plug-in dynamic loading, convenient users quickly, non-stop extension and update.
-
Comprehensive coverage of integration tests + unit tests.
community
Apache ShenYu is an autonomous community open source project completely led by Chinese people. At present, it is in a period of rapid development. A large number of things need to be completed, such as function development, document improvement, BUG repair and so on. The Apache ShenYu community follows the Apache Way community philosophy to create a completely open, governed community. Every two weeks, there’s a full community meeting where committers, coding, and users get involved. That’s where people can talk freely and offer their opinions. For example, discussing different features and codes, it’s better to reach a consensus. In the Apache ShenYu community, we advocate the principle of prioritizing communication between mailing list > Github Issue > wechat group. The main goal is to make every issue, every point of view, documented, to help others better and to advance the sustainable development of the community.
Email subscriptions
- Send a subscription email.
Send an email with any subject or content to [email protected] from your own email address.
- Receive confirmation email and reply.
After completing Step 1, you will receive a confirmation email from [email protected] (if not, please confirm that the email has been blocked or has been automatically assigned to folders such as subscriptions, spam, promotional, etc.). Reply directly to the email, or click on the link in the email to quickly reply with any subject or content.
- Receive the welcome email.
After completing the above steps, you will receive a WELCOME email with the subject line WELCOME to [email protected], so you have successfully subscribed to Apache ShenYu’s mailing list.
GitHub
- Gateway: github.com/apache/incu…
- Front end: github.com/apache/incu…
- Liverpoolfc.tv: github.com/apache/incu…
Gitee
- Gateway: gitee.com/Apache-Shen…
- Front end: gitee.com/Apache-Shen…
- Liverpoolfc.tv: gitee.com/Apache-Shen…