Package com.influxdb.rest
Class ConnectionClosingInterceptor
java.lang.Object
okhttp3.EventListener
com.influxdb.rest.ConnectionClosingInterceptor
- All Implemented Interfaces:
okhttp3.Interceptor
public class ConnectionClosingInterceptor
extends okhttp3.EventListener
implements okhttp3.Interceptor
This interceptor closes connections that exceed a specified maximum lifetime age (TTL). It's beneficial for
scenarios where your application requires establishing new connections to the same host after a predetermined
interval. This interceptor is most effective in applications that use a single connection, meaning requests
are not made in parallel.
Caution is advised, as setting a very short interval can lead to performance issues because establishing new connections is a resource-intensive operation.
-
Nested Class Summary
Nested classes/interfaces inherited from class okhttp3.EventListener
okhttp3.EventListener.Companion, okhttp3.EventListener.Factory
Nested classes/interfaces inherited from interface okhttp3.Interceptor
okhttp3.Interceptor.Chain, okhttp3.Interceptor.Companion
-
Field Summary
Fields inherited from class okhttp3.EventListener
Companion, NONE
Fields inherited from interface okhttp3.Interceptor
Companion
-
Constructor Summary
ConstructorDescriptionConnectionClosingInterceptor
(Duration connectionMaxAge) Create a new interceptor that will close connections older than the given max age. -
Method Summary
Modifier and TypeMethodDescriptionvoid
connectionAcquired
(okhttp3.Call call, okhttp3.Connection connection) okhttp3.Response
intercept
(okhttp3.Interceptor.Chain chain) Methods inherited from class okhttp3.EventListener
cacheConditionalHit, cacheHit, cacheMiss, callEnd, callFailed, callStart, canceled, connectEnd, connectFailed, connectionReleased, connectStart, dnsEnd, dnsStart, proxySelectEnd, proxySelectStart, requestBodyEnd, requestBodyStart, requestFailed, requestHeadersEnd, requestHeadersStart, responseBodyEnd, responseBodyStart, responseFailed, responseHeadersEnd, responseHeadersStart, satisfactionFailure, secureConnectEnd, secureConnectStart
-
Constructor Details
-
ConnectionClosingInterceptor
Create a new interceptor that will close connections older than the given max age.- Parameters:
connectionMaxAge
- the max age of connections, the precision is milliseconds
-
-
Method Details
-
intercept
@Nonnull public okhttp3.Response intercept(@Nonnull okhttp3.Interceptor.Chain chain) throws IOException - Specified by:
intercept
in interfaceokhttp3.Interceptor
- Throws:
IOException
-
connectionAcquired
public void connectionAcquired(@Nonnull okhttp3.Call call, @Nonnull okhttp3.Connection connection) - Overrides:
connectionAcquired
in classokhttp3.EventListener
-