Skip to content
Open
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 @@ -11,22 +11,22 @@ name = "milvus"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tonic = { version = "0.11.0", features = ["tls", "tls-roots"] }
prost = "0.12.6"
tonic = { version = "0.13.1", features = ["tls-native-roots", "prost"] }
prost = ">=0.13, <0.14"
tokio = { version = "1.17.0", features = ["full"] }
thiserror = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0"
strum = "0.24"
strum_macros = "0.24"
base64 = "0.21.0"
base64 = "0.22.1"
dashmap = "5.5.3"
futures = "0.3.31"
lazy_static = "1.4"

[build-dependencies]
tonic-build = { version = "0.11.0", default-features = false, features = [
tonic-build = { version = "0.13", default-features = false, features = [
"prost",
] }

Expand Down
24 changes: 13 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_server(false)
.out_dir("src/proto")
.compile(
&[
"milvus-proto/proto/common.proto",
"milvus-proto/proto/milvus.proto",
"milvus-proto/proto/schema.proto",
],
&["milvus-proto/proto"],
)?;
// Proto files are pre-generated in src/proto/
// To regenerate, install protoc and uncomment below:
// tonic_build::configure()
// .build_server(false)
// .out_dir("src/proto")
// .compile_protos(
// &[
// "milvus-proto/proto/common.proto",
// "milvus-proto/proto/milvus.proto",
// "milvus-proto/proto/schema.proto",
// ],
// &["milvus-proto/proto"],
// )?;
Ok(())
}
10 changes: 5 additions & 5 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use base64::Engine;
use std::collections::HashMap;
use std::convert::TryInto;
use std::time::Duration;
use tonic::codegen::{InterceptedService, StdError};
use tonic::codegen::InterceptedService;
use tonic::service::Interceptor;
use tonic::transport::Channel;
use tonic::Request;
Expand Down Expand Up @@ -101,7 +101,7 @@ pub struct ClientBuilder<D> {
impl<D> ClientBuilder<D>
where
D: TryInto<tonic::transport::Endpoint> + Clone,
D::Error: Into<StdError>,
D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
D::Error: std::fmt::Debug,
{
pub fn new(dst: D) -> Self {
Expand Down Expand Up @@ -152,7 +152,7 @@ impl Client {
pub async fn new<D>(dst: D) -> Result<Self>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError> + std::fmt::Debug,
D::Error: Into<Box<dyn std::error::Error + Send + Sync>> + std::fmt::Debug,
{
Self::with_timeout(dst, RPC_TIMEOUT, None, None).await
}
Expand All @@ -165,7 +165,7 @@ impl Client {
) -> Result<Self>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
D::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
D::Error: std::fmt::Debug,
{
let mut dst: tonic::transport::Endpoint = dst.try_into().map_err(|err| {
Expand All @@ -190,7 +190,7 @@ impl Client {
db: db_interceptor,
};

let channel = tonic::transport::Endpoint::new(dst)?.connect().await?;
let channel = dst.connect().await?;

let client = MilvusServiceClient::with_interceptor(channel.clone(), combined_interceptor);

Expand Down
4 changes: 2 additions & 2 deletions src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl From<proto::milvus::DescribeCollectionResponse> for Collection {
auto_id: schema.auto_id,
num_shards: value.shards_num as usize,
// num_partitions: value.partitions_num as usize,
consistency_level: ConsistencyLevel::from_i32(value.consistency_level).unwrap(),
consistency_level: ConsistencyLevel::try_from(value.consistency_level).unwrap_or(ConsistencyLevel::Strong),
description: schema.description,
fields: schema.fields.into_iter().map(|f| Field::from(f)).collect(),
// enable_dynamic_field: value.enable_dynamic_field,
Expand Down Expand Up @@ -191,7 +191,7 @@ pub struct CompactionState {
impl From<GetCompactionStateResponse> for CompactionState {
fn from(value: GetCompactionStateResponse) -> Self {
Self {
state: crate::proto::common::CompactionState::from_i32(value.state).unwrap(),
state: crate::proto::common::CompactionState::try_from(value.state).unwrap_or(crate::proto::common::CompactionState::UndefiedState),
executing_plan_num: value.executing_plan_no,
timeout_plan_num: value.timeout_plan_no,
completed_plan_num: value.completed_plan_no,
Expand Down
2 changes: 1 addition & 1 deletion src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl From<schema::FieldData> for FieldColumn {
.unwrap_or((Some(1), None));

let value: ValueVec = fd.field.map(Into::into).unwrap_or(ValueVec::None);
let dtype = DataType::from_i32(fd.r#type).unwrap_or(DataType::None);
let dtype = DataType::try_from(fd.r#type).unwrap_or(DataType::None);

FieldColumn {
name: fd.field_name,
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub enum Error {

impl From<Status> for Error {
fn from(s: Status) -> Self {
Error::Server(ErrorCode::from_i32(s.error_code).unwrap(), s.reason)
Error::Server(ErrorCode::try_from(s.error_code).unwrap_or(ErrorCode::UnexpectedError), s.reason)
}
}

Expand Down
Loading