You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2022/06/16 05:15:45 UTC
[incubator-shenyu] branch master updated: [type:refactor] refactor fixed and elastic connection provider pool (#3565)
This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 6c3af8101 [type:refactor] refactor fixed and elastic connection provider pool (#3565)
6c3af8101 is described below
commit 6c3af810153721d0e0eeec60258e00eda366c066
Author: moremind <he...@hotmail.com>
AuthorDate: Thu Jun 16 13:15:38 2022 +0800
[type:refactor] refactor fixed and elastic connection provider pool (#3565)
---
.../httpclient/HttpClientPluginConfiguration.java | 30 +++++++++++++---------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientPluginConfiguration.java b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientPluginConfiguration.java
index b3ab5e3c3..0178c4990 100644
--- a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientPluginConfiguration.java
+++ b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-httpclient/src/main/java/org/apache/shenyu/springboot/starter/plugin/httpclient/HttpClientPluginConfiguration.java
@@ -166,21 +166,21 @@ public class HttpClientPluginConfiguration {
if (pool.getType() == HttpClientProperties.Pool.PoolType.DISABLED) {
connectionProvider = ConnectionProvider.newConnection();
} else if (pool.getType() == HttpClientProperties.Pool.PoolType.FIXED) {
- // TODO moremind add fixed connection pool
- // reactor remove fixed pool from 0.9.4
+ // reactor remove fixed pool by fixed method from 0.9.4
// reason: https://github.com/reactor/reactor-netty/issues/1499 and https://github.com/reactor/reactor-netty/issues/1960
connectionProvider = buildFixedConnectionPool(pool.getName(), pool.getMaxConnections(), pool.getAcquireTimeout(), pool.getMaxIdleTime());
} else {
- // TODO moremind add elastic connection pool
- // reactor remove elastic pool from 0.9.4
+ // please see https://projectreactor.io/docs/netty/release/reference/index.html#_connection_pool_2
+ // reactor remove elastic pool by elastic method from 0.9.4
// reason: https://github.com/reactor/reactor-netty/issues/1499 and https://github.com/reactor/reactor-netty/issues/1960
- connectionProvider = buildFixedConnectionPool(pool.getName(), pool.getMaxConnections(), pool.getAcquireTimeout(), pool.getMaxIdleTime());
+ connectionProvider = buildElasticConnectionPool(pool.getName(), pool.getMaxIdleTime());
}
return connectionProvider;
}
/**
* build fixed connection pool.
+ *
* @param poolName pool name
* @param maxConnections max connections
* @param acquireTimeout pending acquire timeout
@@ -203,14 +203,20 @@ public class HttpClientPluginConfiguration {
}
/**
- * TODO use DefaultPooledConnectionProvider build elastic pool.
- * use {@linkplain reactor.netty.resources DefaultPooledConnectionProvider}.
- * please see: https://github.com/reactor/reactor-netty/blob/main/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultPooledConnectionProvider.java.
- * @param builder build
- * @return elastic pool
+ * build elastic connection provider pool.
+ *
+ * @param poolName pool name
+ * @param maxIdleTime max idle time
+ * @return {@link ConnectionProvider} elastic pool
*/
- public ConnectionProvider buildElasticConnectionPool(final ConnectionProvider.Builder builder) {
- return ConnectionProvider.builder("proxy").build();
+ public ConnectionProvider buildElasticConnectionPool(final String poolName, final Duration maxIdleTime) {
+ // about the args, please see https://projectreactor.io/docs/netty/release/reference/index.html#_connection_pool_2
+ return ConnectionProvider.builder(poolName)
+ .maxConnections(Integer.MAX_VALUE)
+ .pendingAcquireTimeout(Duration.ofMillis(0))
+ .pendingAcquireMaxCount(-1)
+ .maxIdleTime(maxIdleTime)
+ .build();
}
/**