Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tellet-q committed Jan 2, 2025
1 parent 509c5e8 commit c3a957e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/qdrant_client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ pub struct QdrantConfig {

/// Optional compression schema to use for API requests
pub compression: Option<CompressionEncoding>,

/// Whether to check compatibility between the client and server versions
pub check_compatibility: bool,

}

impl QdrantConfig {
Expand Down Expand Up @@ -183,6 +187,7 @@ impl Default for QdrantConfig {
keep_alive_while_idle: true,
api_key: None,
compression: None,
check_compatibility: true,
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/qdrant_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ mod query;
mod search;
mod sharding_keys;
mod snapshot;
// mod version_check;

use std::future::Future;

// use tokio::runtime::Runtime;
use tonic::codegen::InterceptedService;
use tonic::transport::{Channel, Uri};
use tonic::Status;
Expand All @@ -21,6 +22,7 @@ use crate::auth::TokenInterceptor;
use crate::channel_pool::ChannelPool;
use crate::qdrant::{qdrant_client, HealthCheckReply, HealthCheckRequest};
use crate::qdrant_client::config::QdrantConfig;
// use crate::qdrant_client::version_check::health_check_sync;
use crate::QdrantError;

/// [`Qdrant`] client result
Expand Down Expand Up @@ -95,6 +97,7 @@ impl Qdrant {
///
/// Constructs the client and connects based on the given [`QdrantConfig`](config::QdrantConfig).
pub fn new(config: QdrantConfig) -> QdrantResult<Self> {
// let uri = config.uri.clone();
let channel = ChannelPool::new(
config.uri.parse::<Uri>()?,
config.timeout,
Expand All @@ -104,6 +107,15 @@ impl Qdrant {

let client = Self { channel, config };

if client.config.check_compatibility {
let client_version = env!("CARGO_PKG_VERSION").to_string();
// let rt = Runtime::new()?;
// let server_version = rt.block_on(client.health_check())?;
let server_version = tokio::runtime::Handle::current().block_on(client.health_check())?;
println!("Connected to Qdrant version: {}", server_version.version);
println!("Qdrant client version: {}", client_version);
}

Ok(client)
}

Expand Down

0 comments on commit c3a957e

Please sign in to comment.