2828import java .time .Duration ;
2929import java .util .Arrays ;
3030import java .util .HashMap ;
31+ import java .util .List ;
3132import java .util .Map ;
3233import java .util .Objects ;
3334import java .util .Properties ;
3637import javax .annotation .Nonnull ;
3738import javax .annotation .Nullable ;
3839
40+ import io .grpc .ClientInterceptor ;
41+
3942import com .influxdb .v3 .client .write .WriteOptions ;
4043import com .influxdb .v3 .client .write .WritePrecision ;
4144
6871 * <li><code>headers</code> - headers to be added to requests</li>
6972 * <li><code>sslRootsFilePath</code> - path to the stored certificates file in PEM format</li>
7073 * <li><code>disableGRPCCompression</code> - disables the default gRPC compression header</li>
74+ * <li><code>interceptors</code> - list of client interceptors to be used in the query API</li>
7175 * </ul>
7276 * <p>
7377 * If you want to create a client with custom configuration, you can use following code:
@@ -115,6 +119,7 @@ public final class ClientConfig {
115119 private final Map <String , String > headers ;
116120 private final String sslRootsFilePath ;
117121 private final boolean disableGRPCCompression ;
122+ private final List <ClientInterceptor > interceptors ;
118123
119124 /**
120125 * Deprecated use {@link #proxyUrl}.
@@ -329,6 +334,16 @@ public boolean getDisableGRPCCompression() {
329334 return disableGRPCCompression ;
330335 }
331336
337+ /**
338+ * Gets a list of client interceptors.
339+ *
340+ * @return a list of client interceptors.
341+ */
342+ @ Nullable
343+ public List <ClientInterceptor > getInterceptors () {
344+ return interceptors ;
345+ }
346+
332347 /**
333348 * Validates the configuration properties.
334349 */
@@ -366,7 +381,8 @@ public boolean equals(final Object o) {
366381 && Objects .equals (authenticator , that .authenticator )
367382 && Objects .equals (headers , that .headers )
368383 && Objects .equals (sslRootsFilePath , that .sslRootsFilePath )
369- && disableGRPCCompression == that .disableGRPCCompression ;
384+ && disableGRPCCompression == that .disableGRPCCompression
385+ && Objects .equals (interceptors , that .interceptors );
370386 }
371387
372388 @ Override
@@ -375,7 +391,7 @@ public int hashCode() {
375391 database , writePrecision , gzipThreshold , writeNoSync ,
376392 timeout , writeTimeout , queryTimeout , allowHttpRedirects , disableServerCertificateValidation ,
377393 proxy , proxyUrl , authenticator , headers ,
378- defaultTags , sslRootsFilePath , disableGRPCCompression );
394+ defaultTags , sslRootsFilePath , disableGRPCCompression , interceptors );
379395 }
380396
381397 @ Override
@@ -429,6 +445,7 @@ public static final class Builder {
429445 private Map <String , String > headers ;
430446 private String sslRootsFilePath ;
431447 private boolean disableGRPCCompression ;
448+ private List <ClientInterceptor > interceptors ;
432449
433450 /**
434451 * Sets the URL of the InfluxDB server.
@@ -723,6 +740,18 @@ public Builder disableGRPCCompression(final boolean disableGRPCCompression) {
723740 return this ;
724741 }
725742
743+ /**
744+ * Sets a list of interceptors to be used for the query API.
745+ *
746+ * @param interceptors a list of ClientInterceptor
747+ * @return this
748+ */
749+ @ Nonnull
750+ public Builder interceptors (@ Nullable final List <ClientInterceptor > interceptors ) {
751+ this .interceptors = interceptors ;
752+ return this ;
753+ }
754+
726755 /**
727756 * Build an instance of {@code ClientConfig}.
728757 *
@@ -897,5 +926,6 @@ private ClientConfig(@Nonnull final Builder builder) {
897926 headers = builder .headers ;
898927 sslRootsFilePath = builder .sslRootsFilePath ;
899928 disableGRPCCompression = builder .disableGRPCCompression ;
929+ interceptors = builder .interceptors ;
900930 }
901931}
0 commit comments