From 07c2a6c264ea58643ce32e05f3ad846235995916 Mon Sep 17 00:00:00 2001
From: Anush008 <46051506+Anush008@users.noreply.github.com>
Date: Sat, 2 Dec 2023 18:15:31 +0530
Subject: [PATCH] refactor: Move TokenInterceptor
---
README.md | 6 +--
pom.xml | 1 +
.../java/io/qdrant/client/QdrantClient.java | 36 ------------------
.../io/qdrant/client/TokenInterceptor.java | 37 +++++++++++++++++++
4 files changed, 41 insertions(+), 39 deletions(-)
create mode 100644 src/main/java/io/qdrant/client/TokenInterceptor.java
diff --git a/README.md b/README.md
index 2eaeed34..9d33a89d 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@
-
-
+
+
@@ -174,4 +174,4 @@ time: 4.63542E-4
## ⚖️ LICENSE
-Apache 2.0 © [2023](https://github.com/qdrant/java-client/blob/main/LICENSE)
+Apache 2.0 © [2023](https://github.com/qdrant/java-client/blob/master/LICENSE)
diff --git a/pom.xml b/pom.xml
index b3af6fa1..d6361cb9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,6 +6,7 @@
io.qdrant
client
+
1.0
diff --git a/src/main/java/io/qdrant/client/QdrantClient.java b/src/main/java/io/qdrant/client/QdrantClient.java
index 1eb32d79..a5c51be2 100644
--- a/src/main/java/io/qdrant/client/QdrantClient.java
+++ b/src/main/java/io/qdrant/client/QdrantClient.java
@@ -1,14 +1,7 @@
package io.qdrant.client;
-import io.grpc.CallOptions;
-import io.grpc.Channel;
-import io.grpc.ClientCall;
-import io.grpc.ClientInterceptor;
-import io.grpc.ForwardingClientCall.SimpleForwardingClientCall;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
-import io.grpc.Metadata;
-import io.grpc.MethodDescriptor;
import io.qdrant.client.grpc.Collections;
import io.qdrant.client.grpc.CollectionsGrpc;
import io.qdrant.client.grpc.JsonWithInt.Value;
@@ -24,35 +17,6 @@
import java.util.List;
import java.util.Map;
-/** Interceptor for adding an API key to the headers of gRPC requests. */
-class TokenInterceptor implements ClientInterceptor {
- String apiKey;
-
- /**
- * Constructs a new TokenInterceptor with the specified API key.
- *
- * @param apiKey the API key to be added to the headers
- */
- TokenInterceptor(String apiKey) {
- this.apiKey = apiKey;
- }
-
- static final Metadata.Key API_KEY =
- Metadata.Key.of("api-key", Metadata.ASCII_STRING_MARSHALLER);
-
- @Override
- public ClientCall interceptCall(
- MethodDescriptor method, CallOptions callOptions, Channel next) {
- return new SimpleForwardingClientCall(next.newCall(method, callOptions)) {
- @Override
- public void start(Listener responseListener, Metadata headers) {
- headers.put(API_KEY, apiKey);
- super.start(responseListener, headers);
- }
- };
- }
-}
-
/** Client for interfacing with the Qdrant service. */
public class QdrantClient {
private QdrantGrpc.QdrantBlockingStub qdrantStub;
diff --git a/src/main/java/io/qdrant/client/TokenInterceptor.java b/src/main/java/io/qdrant/client/TokenInterceptor.java
new file mode 100644
index 00000000..e04a3e68
--- /dev/null
+++ b/src/main/java/io/qdrant/client/TokenInterceptor.java
@@ -0,0 +1,37 @@
+package io.qdrant.client;
+
+import io.grpc.CallOptions;
+import io.grpc.Channel;
+import io.grpc.ClientCall;
+import io.grpc.ClientInterceptor;
+import io.grpc.ForwardingClientCall.SimpleForwardingClientCall;
+import io.grpc.Metadata;
+import io.grpc.MethodDescriptor;
+
+/** Interceptor for adding an API key to the headers of gRPC requests. */
+final class TokenInterceptor implements ClientInterceptor {
+ private final String apiKey;
+ private final Metadata.Key API_KEY =
+ Metadata.Key.of("api-key", Metadata.ASCII_STRING_MARSHALLER);
+
+ /**
+ * Constructs a new TokenInterceptor with the specified API key.
+ *
+ * @param apiKey the API key to be added to the headers
+ */
+ TokenInterceptor(String apiKey) {
+ this.apiKey = apiKey;
+ }
+
+ @Override
+ public ClientCall interceptCall(
+ MethodDescriptor method, CallOptions callOptions, Channel next) {
+ return new SimpleForwardingClientCall<>(next.newCall(method, callOptions)) {
+ @Override
+ public void start(Listener responseListener, Metadata headers) {
+ headers.put(API_KEY, apiKey);
+ super.start(responseListener, headers);
+ }
+ };
+ }
+}