Skip to content

Commit 843172c

Browse files
authored
Merge pull request #40 from qdrant/tonic-0.9
update to tonic 0.9
2 parents 9292768 + 3da451c commit 843172c

File tree

3 files changed

+1540
-606
lines changed

3 files changed

+1540
-606
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ readme = "README.md"
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[dependencies]
16-
tonic = { version = "0.8.3", features = ["tls", "tls-roots"] }
17-
prost = "0.11.8"
18-
prost-types = "0.11.8"
16+
tonic = { version = "0.9.2", features = ["tls", "tls-roots"] }
17+
prost = "0.11.9"
18+
prost-types = "0.11.9"
1919
anyhow = "1"
2020

2121
# If you don't want to have serde as a dependency, please consider contributing a feature flag
@@ -25,7 +25,7 @@ reqwest = { version = "0.11.16", optional = true, features = ["stream"] }
2525
futures-util = { version = "0.3.28", optional = true }
2626

2727
[dev-dependencies]
28-
tonic-build = { version = "0.8.4", features = ["prost"] }
28+
tonic-build = { version = "0.9.2", features = ["prost"] }
2929
tokio = { version = "1.27.0", features = ["rt-multi-thread"] }
3030

3131
[features]

src/client.rs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,23 @@ pub struct QdrantClient {
228228
}
229229

230230
impl QdrantClient {
231+
/// Wraps a channel with a token interceptor
232+
fn with_api_key(&self, channel: Channel) -> InterceptedService<Channel, TokenInterceptor> {
233+
let interceptor = TokenInterceptor::new(self.cfg.api_key.clone());
234+
InterceptedService::new(channel, interceptor)
235+
}
236+
231237
pub async fn with_snapshot_client<T, O: Future<Output = Result<T, Status>>>(
232238
&self,
233239
f: impl Fn(SnapshotsClient<InterceptedService<Channel, TokenInterceptor>>) -> O,
234240
) -> Result<T, Status> {
235241
self.channel
236242
.with_channel(
237243
|channel| {
238-
f(SnapshotsClient::with_interceptor(
239-
channel,
240-
TokenInterceptor::new(self.cfg.api_key.clone()),
241-
))
244+
let service = self.with_api_key(channel);
245+
let client = SnapshotsClient::new(service);
246+
let client = client.max_decoding_message_size(usize::MAX);
247+
f(client)
242248
},
243249
false,
244250
)
@@ -253,10 +259,10 @@ impl QdrantClient {
253259
self.channel
254260
.with_channel(
255261
|channel| {
256-
f(CollectionsClient::with_interceptor(
257-
channel,
258-
TokenInterceptor::new(self.cfg.api_key.clone()),
259-
))
262+
let service = self.with_api_key(channel);
263+
let client = CollectionsClient::new(service);
264+
let client = client.max_decoding_message_size(usize::MAX);
265+
f(client)
260266
},
261267
false,
262268
)
@@ -271,10 +277,10 @@ impl QdrantClient {
271277
self.channel
272278
.with_channel(
273279
|channel| {
274-
f(PointsClient::with_interceptor(
275-
channel,
276-
TokenInterceptor::new(self.cfg.api_key.clone()),
277-
))
280+
let service = self.with_api_key(channel);
281+
let client = PointsClient::new(service);
282+
let client = client.max_decoding_message_size(usize::MAX);
283+
f(client)
278284
},
279285
true,
280286
)
@@ -289,10 +295,10 @@ impl QdrantClient {
289295
self.channel
290296
.with_channel(
291297
|channel| {
292-
f(qdrant_client::QdrantClient::with_interceptor(
293-
channel,
294-
TokenInterceptor::new(self.cfg.api_key.clone()),
295-
))
298+
let service = self.with_api_key(channel);
299+
let client = qdrant_client::QdrantClient::new(service);
300+
let client = client.max_decoding_message_size(usize::MAX);
301+
f(client)
296302
},
297303
true,
298304
)

0 commit comments

Comments
 (0)