Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/main/java/io/qdrant/client/QdrantGrpcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,14 @@ public void close() {
public static class Builder {
private final ManagedChannel channel;
private final boolean shutdownChannelOnClose;
private final boolean checkCompatibility;
@Nullable private CallCredentials callCredentials;
@Nullable private Duration timeout;

Builder(ManagedChannel channel, boolean shutdownChannelOnClose, boolean checkCompatibility) {
this.channel = channel;
this.shutdownChannelOnClose = shutdownChannelOnClose;
String clientVersion = Builder.class.getPackage().getImplementationVersion();
if (checkCompatibility) {
checkVersionsCompatibility(clientVersion);
}
this.checkCompatibility = checkCompatibility;
}

Builder(String host, int port, boolean useTransportLayerSecurity, boolean checkCompatibility) {
Expand All @@ -210,9 +208,7 @@ public static class Builder {
String userAgent = "java-client/" + clientVersion + " java/" + javaVersion;
this.channel = createChannel(host, port, useTransportLayerSecurity, userAgent);
this.shutdownChannelOnClose = true;
if (checkCompatibility) {
checkVersionsCompatibility(clientVersion);
}
this.checkCompatibility = checkCompatibility;
}

/**
Expand Down Expand Up @@ -255,6 +251,10 @@ public Builder withCallCredentials(@Nullable CallCredentials callCredentials) {
* @return a new instance of {@link QdrantGrpcClient}
*/
public QdrantGrpcClient build() {
if (checkCompatibility) {
String clientVersion = Builder.class.getPackage().getImplementationVersion();
checkVersionsCompatibility(clientVersion);
}
return new QdrantGrpcClient(channel, shutdownChannelOnClose, callCredentials, timeout);
}

Expand All @@ -277,6 +277,7 @@ private void checkVersionsCompatibility(String clientVersion) {
try {
String serverVersion =
QdrantGrpc.newBlockingStub(this.channel)
.withCallCredentials(this.callCredentials)
.healthCheck(QdrantOuterClass.HealthCheckRequest.getDefaultInstance())
.getVersion();
if (!VersionsCompatibilityChecker.isCompatible(clientVersion, serverVersion)) {
Expand Down
Loading