Skip to content

Commit

Permalink
feat: add methods templates of rust
Browse files Browse the repository at this point in the history
  • Loading branch information
smorihira committed Sep 6, 2024
1 parent 51fd488 commit 5636a10
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 290 deletions.
309 changes: 23 additions & 286 deletions rust/Cargo.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
members = [
"libs/observability",
"libs/proto",
"bin/agent",
"libs/algorithm",
"libs/algorithms/ngt",
"libs/algorithms/faiss",
"bin/meta",
# "bin/agent",
# "libs/algorithm",
# "libs/algorithms/ngt",
# "libs/algorithms/faiss", "bin/meta",
]
9 changes: 9 additions & 0 deletions rust/bin/meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "meta"
version = "0.1.0"
edition = "2021"

[dependencies]
proto = { version = "0.1.0", path = "../../libs/proto" }
tokio = { version = "1.40.0", features = ["full"] }
tonic = "0.12.2"
25 changes: 25 additions & 0 deletions rust/bin/meta/src/handler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
mod meta;

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

}




40 changes: 40 additions & 0 deletions rust/bin/meta/src/handler/meta.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

use proto::{meta::v1::meta_server, payload::v1::{meta, Empty}};

#[tonic::async_trait]
impl meta_server::Meta for super::Meta {
async fn get(
&self,
request: tonic::Request<meta::Key>,
) -> std::result::Result<tonic::Response<meta::Value>, tonic::Status> {
todo!()
}
async fn set(
&self,
request: tonic::Request<meta::KeyValue>,
) -> std::result::Result<tonic::Response<Empty>, tonic::Status> {
todo!()
}

async fn delete(
&self,
request: tonic::Request<meta::Key>,
) -> std::result::Result<tonic::Response<Empty>, tonic::Status> {
todo!()
}
}
30 changes: 30 additions & 0 deletions rust/bin/meta/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

mod handler;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "[::1]:8081".parse()?;
let meta = handler::Meta::default();

tonic::transport::Server::builder()
.add_service(proto::meta::v1::meta_server::MetaServer::new(meta))
.serve(addr)
.await?;

Ok(())
}
1 change: 1 addition & 0 deletions rust/libs/proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ edition = "2021"
[dependencies]
futures-core = "0.3.30"
prost = "0.13.1"
prost-types = "0.13.2"
tonic = "0.12.1"
tonic-types = "0.12.1"
6 changes: 6 additions & 0 deletions rust/libs/proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ pub mod core {
include!("core.v1.tonic.rs");
}
}

pub mod meta {
pub mod v1 {
include!("meta.v1.tonic.rs");
}
}

0 comments on commit 5636a10

Please sign in to comment.