diff --git a/src/main/java/io/qdrant/client/QdrantClient.java b/src/main/java/io/qdrant/client/QdrantClient.java index 2f616a6..b311843 100644 --- a/src/main/java/io/qdrant/client/QdrantClient.java +++ b/src/main/java/io/qdrant/client/QdrantClient.java @@ -137,6 +137,19 @@ public QdrantClient(QdrantGrpcClient grpcClient) { this.grpcClient = grpcClient; } + /** + * Gets the low-level gRPC client. This is exposed to + * + * @return The low-level gRPC client + */ + public QdrantGrpcClient grpcClient() { + return grpcClient; + } + /** * Gets detailed information about the qdrant cluster. * diff --git a/src/main/java/io/qdrant/client/QdrantGrpcClient.java b/src/main/java/io/qdrant/client/QdrantGrpcClient.java index e147e15..6a8dea8 100644 --- a/src/main/java/io/qdrant/client/QdrantGrpcClient.java +++ b/src/main/java/io/qdrant/client/QdrantGrpcClient.java @@ -95,6 +95,14 @@ public static Builder newBuilder(String host, int port, boolean useTransportLaye return new Builder(host, port, useTransportLayerSecurity); } + /** + * Gets the channel + * @return the channel + */ + public ManagedChannel channel() { + return channel; + } + /** * Gets the client for qdrant services * @return a new instance of {@link QdrantFutureStub} diff --git a/src/test/java/io/qdrant/client/QdrantClientTest.java b/src/test/java/io/qdrant/client/QdrantClientTest.java new file mode 100644 index 0000000..94ec215 --- /dev/null +++ b/src/test/java/io/qdrant/client/QdrantClientTest.java @@ -0,0 +1,40 @@ +package io.qdrant.client; + +import io.grpc.Grpc; +import io.grpc.InsecureChannelCredentials; +import io.grpc.ManagedChannel; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.qdrant.QdrantContainer; + +@Testcontainers +class QdrantClientTest { + + @Container + private static final QdrantContainer QDRANT_CONTAINER = new QdrantContainer(DockerImage.QDRANT_IMAGE); + private QdrantClient client; + + @BeforeEach + public void setup() { + ManagedChannel channel = Grpc.newChannelBuilder( + QDRANT_CONTAINER.getGrpcHostAddress(), + InsecureChannelCredentials.create()) + .build(); + QdrantGrpcClient grpcClient = QdrantGrpcClient.newBuilder(channel, true).build(); + client = new QdrantClient(grpcClient); + } + + @AfterEach + public void teardown() { + client.close(); + } + + @Test + void canAccessChannelOnGrpcClient() { + Assertions.assertTrue(client.grpcClient().channel().authority().startsWith("localhost")); + } +}