Adds configurable maxLifeTime in HttpClientProperties.
fixes gh-1542
This commit is contained in:
committed by
Spencer Gibb
parent
5786283774
commit
01f314a475
@@ -30,6 +30,7 @@
|
||||
|spring.cloud.gateway.httpclient.pool.acquire-timeout | | Only for type FIXED, the maximum time in millis to wait for aquiring.
|
||||
|spring.cloud.gateway.httpclient.pool.max-connections | | Only for type FIXED, the maximum number of connections before starting pending acquisition on existing ones.
|
||||
|spring.cloud.gateway.httpclient.pool.max-idle-time | | Time in millis after which the channel will be closed. If NULL, there is no max idle time.
|
||||
|spring.cloud.gateway.httpclient.pool.max-life-time | | Duration after which the channel will be closed. If NULL, there is no max life time.
|
||||
|spring.cloud.gateway.httpclient.pool.name | proxy | The channel pool map name, defaults to proxy.
|
||||
|spring.cloud.gateway.httpclient.pool.type | | Type of pool for HttpClient to use, defaults to ELASTIC.
|
||||
|spring.cloud.gateway.httpclient.proxy.host | | Hostname for proxy configuration of Netty HttpClient.
|
||||
|
||||
@@ -591,11 +591,11 @@ public class GatewayAutoConfiguration {
|
||||
else if (pool.getType() == FIXED) {
|
||||
connectionProvider = ConnectionProvider.fixed(pool.getName(),
|
||||
pool.getMaxConnections(), pool.getAcquireTimeout(),
|
||||
pool.getMaxIdleTime());
|
||||
pool.getMaxIdleTime(), pool.getMaxLifeTime());
|
||||
}
|
||||
else {
|
||||
connectionProvider = ConnectionProvider.elastic(pool.getName(),
|
||||
pool.getMaxIdleTime());
|
||||
pool.getMaxIdleTime(), pool.getMaxLifeTime());
|
||||
}
|
||||
|
||||
HttpClient httpClient = HttpClient.create(connectionProvider)
|
||||
|
||||
@@ -178,6 +178,12 @@ public class HttpClientProperties {
|
||||
*/
|
||||
private Duration maxIdleTime = null;
|
||||
|
||||
/**
|
||||
* Duration after which the channel will be closed. If NULL, there is no max life
|
||||
* time.
|
||||
*/
|
||||
private Duration maxLifeTime = null;
|
||||
|
||||
public PoolType getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -218,11 +224,20 @@ public class HttpClientProperties {
|
||||
this.maxIdleTime = maxIdleTime;
|
||||
}
|
||||
|
||||
public Duration getMaxLifeTime() {
|
||||
return maxLifeTime;
|
||||
}
|
||||
|
||||
public void setMaxLifeTime(Duration maxLifeTime) {
|
||||
this.maxLifeTime = maxLifeTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pool{" + "type=" + type + ", name='" + name + '\''
|
||||
+ ", maxConnections=" + maxConnections + ", acquireTimeout="
|
||||
+ acquireTimeout + '}';
|
||||
+ acquireTimeout + ", maxIdleTime=" + maxIdleTime + ", maxLifeTime="
|
||||
+ maxLifeTime + '}';
|
||||
}
|
||||
|
||||
public enum PoolType {
|
||||
|
||||
Reference in New Issue
Block a user