mirror of
https://github.com/qdrant/qdrant.git
synced 2026-09-21 13:37:46 -05:00
Add time to gRPC responses (#9733)
* Add missing time response in some gRPC APIs, make consistent with REST * Don't use destructor
This commit is contained in:
@@ -1080,6 +1080,8 @@ message CollectionClusterInfoResponse {
|
||||
repeated ShardTransferInfo shard_transfers = 5;
|
||||
// Resharding operations
|
||||
repeated ReshardingInfo resharding_operations = 6;
|
||||
// Time spent to process
|
||||
double time = 7;
|
||||
}
|
||||
|
||||
message MoveShard {
|
||||
@@ -1180,6 +1182,8 @@ message UpdateCollectionClusterSetupRequest {
|
||||
|
||||
message UpdateCollectionClusterSetupResponse {
|
||||
bool result = 1;
|
||||
// Time spent to process
|
||||
double time = 2;
|
||||
}
|
||||
|
||||
message CreateShardKeyRequest {
|
||||
@@ -1209,10 +1213,14 @@ message ListShardKeysRequest {
|
||||
|
||||
message CreateShardKeyResponse {
|
||||
bool result = 1;
|
||||
// Time spent to process
|
||||
double time = 2;
|
||||
}
|
||||
|
||||
message DeleteShardKeyResponse {
|
||||
bool result = 1;
|
||||
// Time spent to process
|
||||
double time = 2;
|
||||
}
|
||||
|
||||
message ShardKeyDescription {
|
||||
|
||||
@@ -1951,6 +1951,9 @@ pub struct CollectionClusterInfoResponse {
|
||||
/// Resharding operations
|
||||
#[prost(message, repeated, tag = "6")]
|
||||
pub resharding_operations: ::prost::alloc::vec::Vec<ReshardingInfo>,
|
||||
/// Time spent to process
|
||||
#[prost(double, tag = "7")]
|
||||
pub time: f64,
|
||||
}
|
||||
#[derive(serde::Serialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
@@ -2103,10 +2106,13 @@ pub mod update_collection_cluster_setup_request {
|
||||
}
|
||||
}
|
||||
#[derive(serde::Serialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
|
||||
pub struct UpdateCollectionClusterSetupResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub result: bool,
|
||||
/// Time spent to process
|
||||
#[prost(double, tag = "2")]
|
||||
pub time: f64,
|
||||
}
|
||||
#[derive(serde::Serialize)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
@@ -2145,16 +2151,22 @@ pub struct ListShardKeysRequest {
|
||||
pub collection_name: ::prost::alloc::string::String,
|
||||
}
|
||||
#[derive(serde::Serialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
|
||||
pub struct CreateShardKeyResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub result: bool,
|
||||
/// Time spent to process
|
||||
#[prost(double, tag = "2")]
|
||||
pub time: f64,
|
||||
}
|
||||
#[derive(serde::Serialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
|
||||
pub struct DeleteShardKeyResponse {
|
||||
#[prost(bool, tag = "1")]
|
||||
pub result: bool,
|
||||
/// Time spent to process
|
||||
#[prost(double, tag = "2")]
|
||||
pub time: f64,
|
||||
}
|
||||
#[derive(serde::Serialize)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
|
||||
|
||||
@@ -1607,6 +1607,8 @@ impl From<CollectionClusterInfo> for api::grpc::qdrant::CollectionClusterInfoRes
|
||||
.flatten()
|
||||
.map(ReshardingInfo::into)
|
||||
.collect(),
|
||||
// Overwritten with the real processing time by the API handler
|
||||
time: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,18 +199,21 @@ impl Collections for CollectionsService {
|
||||
mut request: Request<CollectionClusterInfoRequest>,
|
||||
) -> Result<Response<CollectionClusterInfoResponse>, Status> {
|
||||
validate(request.get_ref())?;
|
||||
let timing = Instant::now();
|
||||
let auth = extract_auth(&mut request);
|
||||
|
||||
// Nothing to verify here.
|
||||
let pass = new_unchecked_verification_pass();
|
||||
|
||||
let response = do_get_collection_cluster(
|
||||
let result = do_get_collection_cluster(
|
||||
self.dispatcher.toc(&auth, &pass),
|
||||
&auth,
|
||||
request.into_inner().collection_name.as_str(),
|
||||
)
|
||||
.await?
|
||||
.into();
|
||||
.await?;
|
||||
|
||||
let mut response = CollectionClusterInfoResponse::from(result);
|
||||
response.time = timing.elapsed().as_secs_f64();
|
||||
|
||||
Ok(Response::new(response))
|
||||
}
|
||||
@@ -220,6 +223,7 @@ impl Collections for CollectionsService {
|
||||
mut request: Request<UpdateCollectionClusterSetupRequest>,
|
||||
) -> Result<Response<UpdateCollectionClusterSetupResponse>, Status> {
|
||||
validate(request.get_ref())?;
|
||||
let timing = Instant::now();
|
||||
let auth = extract_auth(&mut request);
|
||||
let UpdateCollectionClusterSetupRequest {
|
||||
collection_name,
|
||||
@@ -239,6 +243,7 @@ impl Collections for CollectionsService {
|
||||
.await?;
|
||||
Ok(Response::new(UpdateCollectionClusterSetupResponse {
|
||||
result,
|
||||
time: timing.elapsed().as_secs_f64(),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -268,6 +273,7 @@ impl Collections for CollectionsService {
|
||||
&self,
|
||||
mut request: Request<CreateShardKeyRequest>,
|
||||
) -> Result<Response<CreateShardKeyResponse>, Status> {
|
||||
let timing = Instant::now();
|
||||
let auth = extract_auth(&mut request);
|
||||
|
||||
let CreateShardKeyRequest {
|
||||
@@ -295,13 +301,17 @@ impl Collections for CollectionsService {
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Response::new(CreateShardKeyResponse { result }))
|
||||
Ok(Response::new(CreateShardKeyResponse {
|
||||
result,
|
||||
time: timing.elapsed().as_secs_f64(),
|
||||
}))
|
||||
}
|
||||
|
||||
async fn delete_shard_key(
|
||||
&self,
|
||||
mut request: Request<DeleteShardKeyRequest>,
|
||||
) -> Result<Response<DeleteShardKeyResponse>, Status> {
|
||||
let timing = Instant::now();
|
||||
let auth = extract_auth(&mut request);
|
||||
|
||||
let DeleteShardKeyRequest {
|
||||
@@ -329,7 +339,10 @@ impl Collections for CollectionsService {
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(Response::new(DeleteShardKeyResponse { result }))
|
||||
Ok(Response::new(DeleteShardKeyResponse {
|
||||
result,
|
||||
time: timing.elapsed().as_secs_f64(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user