Skip to content

Commit

Permalink
fix: Reuse Influx connection pool (#3375)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikriemer authored Dec 16, 2024
1 parent 4c6124d commit 727d146
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@

import org.apache.streampipes.dataexplorer.influx.auth.AuthInterceptor;

import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;

import java.util.concurrent.TimeUnit;

public class InfluxClientUtils {

private static final ConnectionPool connectionPool = new ConnectionPool(10, 10, TimeUnit.MINUTES);

public static OkHttpClient.Builder getHttpClientBuilder(String authToken) {
var builder = getHttpClientBuilder()
.addInterceptor(new AuthInterceptor(authToken));
Expand All @@ -35,6 +38,7 @@ public static OkHttpClient.Builder getHttpClientBuilder(String authToken) {

public static OkHttpClient.Builder getHttpClientBuilder() {
return new OkHttpClient().newBuilder()
.connectionPool(connectionPool)
.connectTimeout(120, TimeUnit.SECONDS)
.readTimeout(120, TimeUnit.SECONDS)
.writeTimeout(120, TimeUnit.SECONDS);
Expand Down

0 comments on commit 727d146

Please sign in to comment.