-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose gRPC client on high level client (#27)
This commit exposes the low-level gRPC client on the high level client, for two purposes: - Allow access to the underlying gRPC channel. This may be useful for capturing properties about the channel e.g. the channel authority, for metrics. - Allow access to the gRPC client to make requests using the low-level gRPC client in cases where functionality may not yet be exposed by the higher level client.
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")); | ||
} | ||
} |