Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tonic = { version = "0.8.3", features = ["tls", "tls-roots"] }
prost = "0.11.8"
prost-types = "0.11.8"
tonic = { version = "0.9.2", features = ["tls", "tls-roots"] }
prost = "0.11.9"
prost-types = "0.11.9"
anyhow = "1"

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

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

[features]
Expand Down
38 changes: 22 additions & 16 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,23 @@ pub struct QdrantClient {
}

impl QdrantClient {
/// Wraps a channel with a token interceptor
fn with_api_key(&self, channel: Channel) -> InterceptedService<Channel, TokenInterceptor> {
let interceptor = TokenInterceptor::new(self.cfg.api_key.clone());
InterceptedService::new(channel, interceptor)
}

pub async fn with_snapshot_client<T, O: Future<Output = Result<T, Status>>>(
&self,
f: impl Fn(SnapshotsClient<InterceptedService<Channel, TokenInterceptor>>) -> O,
) -> Result<T, Status> {
self.channel
.with_channel(
|channel| {
f(SnapshotsClient::with_interceptor(
channel,
TokenInterceptor::new(self.cfg.api_key.clone()),
))
let service = self.with_api_key(channel);
let client = SnapshotsClient::new(service);
let client = client.max_decoding_message_size(usize::MAX);
f(client)
},
false,
)
Expand All @@ -253,10 +259,10 @@ impl QdrantClient {
self.channel
.with_channel(
|channel| {
f(CollectionsClient::with_interceptor(
channel,
TokenInterceptor::new(self.cfg.api_key.clone()),
))
let service = self.with_api_key(channel);
let client = CollectionsClient::new(service);
let client = client.max_decoding_message_size(usize::MAX);
f(client)
},
false,
)
Expand All @@ -271,10 +277,10 @@ impl QdrantClient {
self.channel
.with_channel(
|channel| {
f(PointsClient::with_interceptor(
channel,
TokenInterceptor::new(self.cfg.api_key.clone()),
))
let service = self.with_api_key(channel);
let client = PointsClient::new(service);
let client = client.max_decoding_message_size(usize::MAX);
f(client)
},
true,
)
Expand All @@ -289,10 +295,10 @@ impl QdrantClient {
self.channel
.with_channel(
|channel| {
f(qdrant_client::QdrantClient::with_interceptor(
channel,
TokenInterceptor::new(self.cfg.api_key.clone()),
))
let service = self.with_api_key(channel);
let client = qdrant_client::QdrantClient::new(service);
let client = client.max_decoding_message_size(usize::MAX);
f(client)
},
true,
)
Expand Down
Loading