Skip to content

Commit

Permalink
implement prototype of agent grpc server
Browse files Browse the repository at this point in the history
  • Loading branch information
kmrmt committed May 7, 2024
1 parent 9c12b90 commit 0c207af
Show file tree
Hide file tree
Showing 13 changed files with 460 additions and 29 deletions.
142 changes: 121 additions & 21 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

[dependencies]
ngt = { version = "0.1.0", path = "../../libs/ngt" }
prost = "0.12.4"
proto = { version = "0.1.0", path = "../../libs/proto" }
tokio = { version = "1.37.0", features = ["full"] }
tokio-stream = { version = "0.1.15", features = ["full"] }
tonic = "0.11.0"
12 changes: 12 additions & 0 deletions rust/bin/agent/src/handler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mod common;
mod index;
mod insert;
mod remove;
mod search;
mod update;
mod upsert;

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

}
6 changes: 6 additions & 0 deletions rust/bin/agent/src/handler/common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[macro_export]
macro_rules! stream_type {
($t:ty) => {
std::pin::Pin<Box<dyn tokio_stream::Stream<Item = std::result::Result<$t, tonic::Status>> + Send>>
};
}
45 changes: 45 additions & 0 deletions rust/bin/agent/src/handler/index.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use proto::{
core::v1::agent_server,
payload::v1::{control, info, object, Empty},
};

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

async fn save_index(
&self,
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>,
) -> std::result::Result<tonic::Response<Empty>, tonic::Status> {
todo!()
}

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

#[doc = " Represent the RPC to get the vector metadata. This RPC is mainly used for index correction process\n"]
async fn get_timestamp(
&self,
request: tonic::Request<object::GetTimestampRequest>,
) -> std::result::Result<tonic::Response<object::Timestamp>, tonic::Status> {
todo!()
}
}
Loading

0 comments on commit 0c207af

Please sign in to comment.