@@ -98,17 +98,16 @@ impl Qdrant {
9898 ///
9999 /// Constructs the client and connects based on the given [`QdrantConfig`](config::QdrantConfig).
100100 pub fn new ( config : QdrantConfig ) -> QdrantResult < Self > {
101- let check_compatibility = config. check_compatibility ;
102- let channel = ChannelPool :: new (
103- config . uri . parse :: < Uri > ( ) ? ,
104- config. timeout ,
105- config. connect_timeout ,
106- config. keep_alive_while_idle ,
107- ) ;
108-
109- let client = Self { channel, config } ;
101+ if config. check_compatibility {
102+ // create a temporary client to check compatibility
103+ let channel = ChannelPool :: new (
104+ config. uri . parse :: < Uri > ( ) ? ,
105+ config. timeout ,
106+ config. connect_timeout ,
107+ config . keep_alive_while_idle ,
108+ ) ;
109+ let client = Self { channel, config : config . clone ( ) } ;
110110
111- if check_compatibility {
112111 // We're in sync context, spawn temporary runtime in thread to do async health check
113112 let server_version = thread:: scope ( |s| {
114113 s. spawn ( || {
@@ -120,7 +119,7 @@ impl Qdrant {
120119 . block_on ( client. health_check ( ) )
121120 } )
122121 . join ( )
123- . unwrap ( )
122+ . expect ( "Failed to join health check thread" )
124123 } )
125124 . ok ( )
126125 . map ( |info| info. version ) ;
@@ -142,6 +141,15 @@ impl Qdrant {
142141 }
143142 }
144143
144+ let channel = ChannelPool :: new (
145+ config. uri . parse :: < Uri > ( ) ?,
146+ config. timeout ,
147+ config. connect_timeout ,
148+ config. keep_alive_while_idle ,
149+ ) ;
150+
151+ let client = Self { channel, config } ;
152+
145153 Ok ( client)
146154 }
147155
0 commit comments