diff --git a/src/qdrant_client/config.rs b/src/qdrant_client/config.rs index 15ddf5f..9ed5481 100644 --- a/src/qdrant_client/config.rs +++ b/src/qdrant_client/config.rs @@ -16,6 +16,7 @@ use crate::{Qdrant, QdrantError}; /// .compression(Some(CompressionEncoding::Gzip)) /// .build(); /// ``` +#[derive(Clone)] pub struct QdrantConfig { /// Qdrant server URI to connect to pub uri: String, diff --git a/src/qdrant_client/mod.rs b/src/qdrant_client/mod.rs index f666ed7..3894f4c 100644 --- a/src/qdrant_client/mod.rs +++ b/src/qdrant_client/mod.rs @@ -98,17 +98,16 @@ impl Qdrant { /// /// Constructs the client and connects based on the given [`QdrantConfig`](config::QdrantConfig). pub fn new(config: QdrantConfig) -> QdrantResult { - let check_compatibility = config.check_compatibility; - let channel = ChannelPool::new( - config.uri.parse::()?, - config.timeout, - config.connect_timeout, - config.keep_alive_while_idle, - ); - - let client = Self { channel, config }; + if config.check_compatibility { + // create a temporary client to check compatibility + let channel = ChannelPool::new( + config.uri.parse::()?, + config.timeout, + config.connect_timeout, + config.keep_alive_while_idle, + ); + let client = Self { channel, config: config.clone() }; - if check_compatibility { // We're in sync context, spawn temporary runtime in thread to do async health check let server_version = thread::scope(|s| { s.spawn(|| { @@ -120,7 +119,7 @@ impl Qdrant { .block_on(client.health_check()) }) .join() - .unwrap() + .expect("Failed to join health check thread") }) .ok() .map(|info| info.version); @@ -142,6 +141,15 @@ impl Qdrant { } } + let channel = ChannelPool::new( + config.uri.parse::()?, + config.timeout, + config.connect_timeout, + config.keep_alive_while_idle, + ); + + let client = Self { channel, config }; + Ok(client) }