use of io.reactivex.netty.pipeline.ssl.SSLEngineFactory in project ribbon by Netflix.
the class LoadBalancingHttpClient method createRxClient.
@Override
protected HttpClient<I, O> createRxClient(Server server) {
HttpClientBuilder<I, O> clientBuilder;
if (requestIdProvider != null) {
clientBuilder = RxContexts.<I, O>newHttpClientBuilder(server.getHost(), server.getPort(), requestIdProvider, RxContexts.DEFAULT_CORRELATOR, pipelineConfigurator);
} else {
clientBuilder = RxContexts.<I, O>newHttpClientBuilder(server.getHost(), server.getPort(), RxContexts.DEFAULT_CORRELATOR, pipelineConfigurator);
}
Integer connectTimeout = getProperty(IClientConfigKey.Keys.ConnectTimeout, null, DefaultClientConfigImpl.DEFAULT_CONNECT_TIMEOUT);
Integer readTimeout = getProperty(IClientConfigKey.Keys.ReadTimeout, null, DefaultClientConfigImpl.DEFAULT_READ_TIMEOUT);
Boolean followRedirect = getProperty(IClientConfigKey.Keys.FollowRedirects, null, null);
HttpClientConfig.Builder builder = new HttpClientConfig.Builder().readTimeout(readTimeout, TimeUnit.MILLISECONDS);
if (followRedirect != null) {
builder.setFollowRedirect(followRedirect);
}
clientBuilder.channelOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout).config(builder.build());
if (isPoolEnabled()) {
clientBuilder.withConnectionPoolLimitStrategy(poolStrategy).withIdleConnectionsTimeoutMillis(idleConnectionEvictionMills).withPoolIdleCleanupScheduler(poolCleanerScheduler);
} else {
clientBuilder.withNoConnectionPooling();
}
if (sslContextFactory != null) {
try {
SSLEngineFactory myFactory = new DefaultFactories.SSLContextBasedFactory(sslContextFactory.getSSLContext()) {
@Override
public SSLEngine createSSLEngine(ByteBufAllocator allocator) {
SSLEngine myEngine = super.createSSLEngine(allocator);
myEngine.setUseClientMode(true);
return myEngine;
}
};
clientBuilder.withSslEngineFactory(myFactory);
} catch (ClientSslSocketFactoryException e) {
throw new RuntimeException(e);
}
}
return clientBuilder.build();
}
Aggregations