Skip to content

Commit

Permalink
implement richer error model
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <[email protected]>
  • Loading branch information
kmrmt committed Aug 26, 2024
1 parent 4202915 commit 603d25a
Show file tree
Hide file tree
Showing 12 changed files with 2,893 additions and 176 deletions.
2,786 changes: 2,666 additions & 120 deletions rust/Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions rust/bin/agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ edition = "2021"

[dependencies]
algorithm = { version = "0.1.0", path = "../../libs/algorithm" }
anyhow = "1.0.86"
cargo = "0.81.0"
prost = "0.13.1"
prost-types = "0.13.1"
proto = { version = "0.1.0", path = "../../libs/proto" }
tokio = { version = "1.39.3", features = ["full"] }
tokio-stream = { version = "0.1.15", features = ["full"] }
tonic = "0.12.1"
tonic-types = "0.12.1"
32 changes: 24 additions & 8 deletions rust/bin/agent/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,30 @@
// limitations under the License.
//
mod common;
mod index;
mod insert;
mod remove;
mod search;
mod update;
mod upsert;
pub mod index;
pub mod insert;
pub mod remove;
pub mod search;
pub mod update;
pub mod upsert;

#[derive(Default, Debug)]
#[derive(Debug)]
pub struct Agent {

s: &dyn algorithm::ANN,
name: String,
ip: String,
resource_type: String,
api_name: String,
}

impl Agent {
pub fn new(s: impl algorithm::ANN, name: &str, ip: &str, resource_type: &str, api_name: &str) -> Agent {
Agent {
s: s,
name: name.to_string(),
ip: ip.to_string(),
resource_type: resource_type.to_string(),
api_name: api_name.to_string(),
}
}
}
18 changes: 9 additions & 9 deletions rust/bin/agent/src/handler/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@
//
use proto::{
core::v1::agent_server,
payload::v1::{control, info, object, Empty},
payload::v1::{control, info, Empty},
vald::v1::index_server,
};

#[tonic::async_trait]
impl agent_server::Agent for super::Agent {
async fn create_index(
&self,
request: tonic::Request<control::CreateIndexRequest>,
_request: tonic::Request<control::CreateIndexRequest>,
) -> std::result::Result<tonic::Response<Empty>, tonic::Status> {
todo!()
}

async fn save_index(
&self,
request: tonic::Request<Empty>,
_request: tonic::Request<Empty>,
) -> std::result::Result<tonic::Response<Empty>, tonic::Status> {
todo!()
}

#[doc = " Represent the creating and saving index RPC.\n"]
async fn create_and_save_index(
&self,
request: tonic::Request<control::CreateIndexRequest>,
_request: tonic::Request<control::CreateIndexRequest>,
) -> std::result::Result<tonic::Response<Empty>, tonic::Status> {
todo!()
}
Expand All @@ -49,38 +49,38 @@ impl index_server::Index for super::Agent {
#[doc = " Represent the RPC to get the agent index information.\n"]
async fn index_info(
&self,
request: tonic::Request<Empty>,
_request: tonic::Request<Empty>,
) -> std::result::Result<tonic::Response<info::index::Count>, tonic::Status> {
todo!()
}

#[doc = " Represent the RPC to get the agent index detailed information.\n"]
async fn index_detail(
&self,
request: tonic::Request<Empty>,
_request: tonic::Request<Empty>,
) -> std::result::Result<tonic::Response<info::index::Detail>, tonic::Status> {
todo!()
}
#[doc = " Represent the RPC to get the agent index statistics.\n"]
async fn index_statistics(
&self,
request: tonic::Request<Empty>,
_request: tonic::Request<Empty>,
) -> std::result::Result<tonic::Response<info::index::Statistics>, tonic::Status> {
todo!()
}

#[doc = " Represent the RPC to get the agent index detailed statistics.\n"]
async fn index_statistics_detail(
&self,
request: tonic::Request<Empty>,
_request: tonic::Request<Empty>,
) -> std::result::Result<tonic::Response<info::index::StatisticsDetail>, tonic::Status> {
todo!()
}

#[doc = " Represent the RPC to get the index property.\n"]
async fn index_property(
&self,
request: tonic::Request<Empty>,
_request: tonic::Request<Empty>,
) -> std::result::Result<tonic::Response<info::index::PropertyDetail>, tonic::Status> {
todo!()
}
Expand Down
6 changes: 3 additions & 3 deletions rust/bin/agent/src/handler/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use proto::{
impl insert_server::Insert for super::Agent {
async fn insert(
&self,
request: tonic::Request<insert::Request>,
_request: tonic::Request<insert::Request>,
) -> std::result::Result<tonic::Response<object::Location>, tonic::Status> {
todo!()
}
Expand All @@ -32,15 +32,15 @@ impl insert_server::Insert for super::Agent {
#[doc = " A method to add new multiple vectors by bidirectional streaming.\n"]
async fn stream_insert(
&self,
request: tonic::Request<tonic::Streaming<insert::Request>>,
_request: tonic::Request<tonic::Streaming<insert::Request>>,
) -> std::result::Result<tonic::Response<Self::StreamInsertStream>, tonic::Status> {
todo!()
}

#[doc = " A method to add new multiple vectors in a single request.\n"]
async fn multi_insert(
&self,
request: tonic::Request<insert::MultiRequest>,
_request: tonic::Request<insert::MultiRequest>,
) -> std::result::Result<tonic::Response<object::Locations>, tonic::Status> {
todo!()
}
Expand Down
8 changes: 4 additions & 4 deletions rust/bin/agent/src/handler/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ use proto::{
impl remove_server::Remove for super::Agent {
async fn remove(
&self,
request: tonic::Request<remove::Request>,
_request: tonic::Request<remove::Request>,
) -> std::result::Result<tonic::Response<object::Location>, tonic::Status> {
todo!()
}

#[doc = " A method to remove an indexed vector based on timestamp.\n"]
async fn remove_by_timestamp(
&self,
request: tonic::Request<remove::TimestampRequest>,
_request: tonic::Request<remove::TimestampRequest>,
) -> std::result::Result<tonic::Response<object::Locations>, tonic::Status> {
todo!()
}
Expand All @@ -41,15 +41,15 @@ impl remove_server::Remove for super::Agent {
#[doc = " A method to remove multiple indexed vectors by bidirectional streaming.\n"]
async fn stream_remove(
&self,
request: tonic::Request<tonic::Streaming<remove::Request>>,
_request: tonic::Request<tonic::Streaming<remove::Request>>,
) -> std::result::Result<tonic::Response<Self::StreamRemoveStream>, tonic::Status> {
todo!()
}

#[doc = " A method to remove multiple indexed vectors in a single request.\n"]
async fn multi_remove(
&self,
request: tonic::Request<remove::MultiRequest>,
_request: tonic::Request<remove::MultiRequest>,
) -> std::result::Result<tonic::Response<object::Locations>, tonic::Status> {
todo!()
}
Expand Down
Loading

0 comments on commit 603d25a

Please sign in to comment.