foreword
After 4 months, Apache ShenYu ushered in a major version of 2.5.0. In this version, there are 300+ pull requests, 60+ contributors participated in submission, 88000+ lines of code added or modified, this version Lots of optimizations, let’s see what this version has done. The following are just some of the more important functions.
log function
- Added connection to Alibaba Cloud SLS log plug-in
Specific use reference: https://shenyu.apache.org/zh/docs/plugin-center/observability/logging-aliyun-sls/
- Added connection to Elastic Search log plugin
Specific use reference: https://shenyu.apache.org/zh/docs/plugin-center/observability/logging-elasticsearch
- Added connection to Apache RocketMQ log plugin
Specific use reference: https://shenyu.apache.org/zh/docs/plugin-center/observability/logging-rocketmq
- Added log plugin for connecting to Apache Kafka
Specific use reference: https://shenyu.apache.org/zh/docs/plugin-center/observability/logging-kafka
new function
Added mock plugin.
Specify the response status code and response body for the request to facilitate testing. Supports setting the response status code and response body of the request.Support configuration ${int|min-max}
, ${double|min-max|format}
, ${email}
, ${phone}
, ${zh|min-max}
, ${list|[arg1,arg2...]}
, ${array|item|length}
and other placeholders to automatically generate data.
Specific use reference: https://shenyu.apache.org/zh/docs/plugin-center/mock/mock-plugin
Users can also custom develop other placeholders:
Specific development: https://shenyu.apache.org/zh/docs/developer/spi/custom-mock-generator
Custom output results in the response plugin
ShenYu code:
@Bean
public ShenyuPlugin responsePlugin(final ObjectProvider<List<MessageWriter>> httpWriter) {
Map<String, MessageWriter> writerMap = new LinkedHashMap<>();
List<MessageWriter> writerList = httpWriter.getIfAvailable(ArrayList::new);
for (MessageWriter writer : writerList) {
List<String> supportTypes = writer.supportTypes();
for (String type : supportTypes) {
writerMap.put(type, writer);
}
}
return new ResponsePlugin(writerMap);
}
User-defined implementation: rg.apache.shenyu.plugin.response.strategy.MessageWriter
/**
* The interface Message writer.
*/
public interface MessageWriter {
/**
* Write with exchange and shenyu plugin chain.
*
* @param exchange exchange the current server exchange
* @param chain provides a way to delegate to the next filter
* @return {@code Mono<Void>} to indicate when request processing is complete
*/
Mono<Void> writeWith(ServerWebExchange exchange, ShenyuPluginChain chain);
/**
* Support type list.
*
* @return the list
*/
List<String> supportTypes();
}
Registration Center
The purpose of ShenYu’s registry is to expose the instance of the gateway in order to support ShenYu’s cluster function. You can use the shenyu-nginx project or connect to other load balancing services.
ShenYu-Nginx: https://github.com/apache/shenyu-nginx
Added support for Nacos
Use: Add the following configuration to the yaml of the gateway bootstarp:
shenyu :
instance:
enabled: true //设置true表示打开
registerType: nacos //类型为nacos
serverLists: localhost:8848
props:
Added support for Consul
Use: Add the following configuration to the yaml of the gateway bootstarp:
shenyu :
instance:
enabled: true //设置true表示打开
registerType: consul //类型为consul
serverLists: localhost:2379
props:
performance optimization
Upgrade SpringBoot to 2.6.8 and Reactor-netty to 1.0.19
The gateway customizes Netty full parameter configuration.Meet the user’s personalized configuration
For details, please refer to: https://shenyu.apache.org/zh/docs/user-guide/property-config/gateway-property-config
Added matching cache policy.The flow matching efficiency is O(1)
.
How to use? Configure it in the gateway’s yaml file:
shenyu:
matchCache:
enabled: true //设置为true 开启
maxFreeMemory: 256 # //内存大小 单位M
Added custom thread shared thread pool.
How to use? Configure it in the gateway’s yaml file:
shenyu:
sharedPool:
enable: true
prefix: "shenyu-shared"
corePoolSize: 200
maximumPoolSize: 2000
keepAliveTime: 60000
maxWorkQueueMemory: 1073741824 # 1GB
maxFreeMemory: 268435456 # 256MB
Principle: Customize the shenyu thread pool, rewrite the queue, etc. Specifically, you can view the following code:
Management and control platform
- Data storage added support for oracle database.
- Added API document management function.
- Added logging to the ShenYu Admin management console.
- More….
refactor
Refactored spring cloud plugin load balancing.
Refactor IpUtils to get ip logic.
Zookeeper client replaced with Apache Curator.
Refactor ShenYu Java Client registration logic.
More….
BugFix
- Fix divide plugin null pointer exception.
- Fix the exception that the body is too large.
- Fix Java client registration, loop error.
- Fix Grpc client registration bug.
- Fixed an issue where loading local plugins failed.
- Fix the problem that Consul registration only registers 1 metadata.
- Fix CSRF attack when using Websocket to sync data.
- Fix Admin pg script errors.
- More….
Contributor
Special thanks to the contributors who supported 2.5.0, in no particular order.
dragon-zhang,renzhuyan,moremind,xiaoyu,likeguo,qinghai777,Kevin, Qicz,,yunlongn,lianjunwei,zhengpeng,Han,weihubeats,Zihao, DamonXue(Fibonacci),Luke.Z,ShawnSiao,sunshujie1990,Codd,dayu, LiuTianyou, PJ,Sixh-PrFor,ChineseTony,chuang,erdengk,hutaishi,impactCn, Jiageng,lahmxu,qifanyyy,Shawn,SongTao,zouchangfu,damonxue,Kunshuai, mango,nuo-promise,Salted,Seth,SongTaoZhuang,wklong,AhahaGe,Bigbang, Chencheng,Dongx,Ethan,haibo.duan,Haitao,huanccwang,jerbo99,Lidyaqf Liming,midnight2104,Nick-fengzl,ningminglong,Rubén,Shuaiqi,vijay wjlonger,Zhang,zhc,Zhiqiang,ZZQ
About Apache ShenYu
Apache ShenYu is a reactive API gateway developed with Java Reactor. With its high performance, dynamic and flexible traffic control, hot swap, easy deployment and other features, it provides users with a complete set of full life cycle API gateways out of the box, including functions such as API registration, service proxy, protocol conversion and API governance. Graduated as an Apache top-level project in July 2022.
#Apache #ShenYu #releases #News Fast Delivery