Search in sources :

Example 1 with OkHttpClient

use of feign.okhttp.OkHttpClient in project atlasdb by palantir.

the class FeignOkHttpClients method newRawOkHttpClient.

@VisibleForTesting
static okhttp3.OkHttpClient newRawOkHttpClient(Optional<SSLSocketFactory> sslSocketFactory, Optional<ProxySelector> proxySelector, String userAgent) {
    // Don't allow retrying on connection failures - see ticket #2194
    okhttp3.OkHttpClient.Builder builder = new okhttp3.OkHttpClient.Builder().connectionSpecs(CONNECTION_SPEC_WITH_CYPHER_SUITES).connectionPool(new ConnectionPool(CONNECTION_POOL_SIZE, KEEP_ALIVE_TIME_MILLIS, TimeUnit.MILLISECONDS)).proxySelector(proxySelector.orElse(ProxySelector.getDefault())).retryOnConnectionFailure(false);
    if (sslSocketFactory.isPresent()) {
        builder.sslSocketFactory(sslSocketFactory.get());
    }
    builder.interceptors().add(new UserAgentAddingInterceptor(userAgent));
    globalClientSettings.accept(builder);
    return builder.build();
}
Also used : ConnectionPool(okhttp3.ConnectionPool) OkHttpClient(feign.okhttp.OkHttpClient) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 OkHttpClient (feign.okhttp.OkHttpClient)1 ConnectionPool (okhttp3.ConnectionPool)1