Skip to content

Commit

Permalink
Merge pull request #339 from weaviate/revert-337-add-support-for-asyn…
Browse files Browse the repository at this point in the history
…c-connection-manager

Revert "Add PoolingAsyncClientConnectionManager to async http client"
  • Loading branch information
antas-marcin authored Nov 26, 2024
2 parents bbdcdbb + 9262251 commit d7f7573
Showing 1 changed file with 0 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,51 +1,19 @@
package io.weaviate.client.base.http.async;

import io.weaviate.client.Config;
import org.apache.hc.client5.http.config.ConnectionConfig;
import org.apache.hc.client5.http.config.TlsConfig;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager;
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.ClientTlsStrategyBuilder;
import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.pool.PoolConcurrencyPolicy;
import org.apache.hc.core5.pool.PoolReusePolicy;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;

public class AsyncHttpClient {

public static final TimeValue TIME_TO_LIVE = TimeValue.ofMinutes(10);

public static CloseableHttpAsyncClient create(Config config) {
PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManagerBuilder.create()
.setTlsStrategy(ClientTlsStrategyBuilder.create()
.setSslContext(SSLContexts.createSystemDefault())
.setTlsVersions(TLS.V_1_3)
.build())
.setPoolConcurrencyPolicy(PoolConcurrencyPolicy.STRICT)
.setConnPoolPolicy(PoolReusePolicy.LIFO)
.setDefaultConnectionConfig(ConnectionConfig.custom()
.setSocketTimeout(Timeout.ofSeconds(config.getSocketTimeout()))
.setConnectTimeout(Timeout.ofSeconds(config.getConnectionTimeout()))
.setTimeToLive(TIME_TO_LIVE)
.build())
.setDefaultTlsConfig(TlsConfig.custom()
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setHandshakeTimeout(Timeout.ofSeconds(config.getConnectionRequestTimeout()))
.build())
.build();

IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
.setSoTimeout(Timeout.ofSeconds(config.getSocketTimeout()))
.build();

return HttpAsyncClients.custom()
.setConnectionManager(connectionManager)
.setIOReactorConfig(ioReactorConfig)
.build();
}
Expand Down

0 comments on commit d7f7573

Please sign in to comment.