From 5636a1015b19c086c2563333c7fe7d75eb7492b9 Mon Sep 17 00:00:00 2001 From: smorihira Date: Fri, 6 Sep 2024 17:49:43 +0900 Subject: [PATCH] feat: add methods templates of rust --- rust/Cargo.lock | 309 +++--------------------------- rust/Cargo.toml | 9 +- rust/bin/meta/Cargo.toml | 9 + rust/bin/meta/src/handler.rs | 25 +++ rust/bin/meta/src/handler/meta.rs | 40 ++++ rust/bin/meta/src/main.rs | 30 +++ rust/libs/proto/Cargo.toml | 1 + rust/libs/proto/src/lib.rs | 6 + 8 files changed, 139 insertions(+), 290 deletions(-) create mode 100644 rust/bin/meta/Cargo.toml create mode 100644 rust/bin/meta/src/handler.rs create mode 100644 rust/bin/meta/src/handler/meta.rs create mode 100644 rust/bin/meta/src/main.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index a41a430640..9fcf401f91 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -17,26 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "agent" -version = "0.1.0" -dependencies = [ - "algorithm", - "prost 0.13.1", - "proto", - "tokio", - "tokio-stream", - "tonic 0.12.1", -] - -[[package]] -name = "algorithm" -version = "0.1.0" -dependencies = [ - "faiss", - "ngt", -] - [[package]] name = "anyhow" version = "1.0.86" @@ -195,15 +175,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "backtrace-ext" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50" -dependencies = [ - "backtrace", -] - [[package]] name = "base64" version = "0.21.7" @@ -261,16 +232,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -287,50 +248,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "cxx" -version = "1.0.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c4eae4b7fc8dcb0032eb3b1beee46b38d371cdeaf2d0c64b9944f6f69ad7755" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c822bf7fb755d97328d6c337120b6f843678178751cba33c9da25cf522272e0" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719d6197dc016c88744aff3c0d0340a01ecce12e8939fc282e7c8f583ee64bc6" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35de3b547387863c8f82013c4f79f1c2162edee956383e4089e1d04c18c4f16c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "either" version = "1.13.0" @@ -352,20 +269,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "faiss" -version = "0.1.0" - [[package]] name = "fnv" version = "1.0.7" @@ -726,12 +629,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[package]] -name = "is_ci" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" - [[package]] name = "itertools" version = "0.12.1" @@ -777,21 +674,6 @@ version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" -[[package]] -name = "link-cplusplus" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" -dependencies = [ - "cc", -] - -[[package]] -name = "linux-raw-sys" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" - [[package]] name = "lock_api" version = "0.4.12" @@ -821,34 +703,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "miette" -version = "7.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4edc8853320c2a0dab800fbda86253c8938f6ea88510dc92c5f1ed20e794afc1" -dependencies = [ - "backtrace", - "backtrace-ext", - "cfg-if", - "miette-derive", - "owo-colors", - "supports-color", - "supports-hyperlinks", - "supports-unicode", - "terminal_size", - "textwrap", - "thiserror", - "unicode-width", -] - -[[package]] -name = "miette-derive" -version = "7.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" +name = "meta" +version = "0.1.0" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proto", + "tokio", + "tonic 0.12.2", ] [[package]] @@ -878,17 +738,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ngt" -version = "0.1.0" -dependencies = [ - "anyhow", - "cxx", - "cxx-build", - "miette", - "rand", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -1026,12 +875,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "owo-colors" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" - [[package]] name = "parking_lot" version = "0.12.3" @@ -1129,12 +972,12 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +checksum = "3b2ecbe40f08db5c006b5764a2645f7f3f141ce756412ac9e1dd6087e6d32995" dependencies = [ "bytes", - "prost-derive 0.13.1", + "prost-derive 0.13.2", ] [[package]] @@ -1152,9 +995,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" dependencies = [ "anyhow", "itertools 0.13.0", @@ -1165,11 +1008,11 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +checksum = "60caa6738c7369b940c3d49246a8d1749323674c65cb13010134f5c9bad5b519" dependencies = [ - "prost 0.13.1", + "prost 0.13.2", ] [[package]] @@ -1177,8 +1020,9 @@ name = "proto" version = "0.1.0" dependencies = [ "futures-core", - "prost 0.13.1", - "tonic 0.12.1", + "prost 0.13.2", + "prost-types", + "tonic 0.12.2", "tonic-types", ] @@ -1272,19 +1116,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustix" -version = "0.38.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" -dependencies = [ - "bitflags 2.6.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - [[package]] name = "rustversion" version = "1.0.17" @@ -1303,12 +1134,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "scratch" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" - [[package]] name = "serde" version = "1.0.208" @@ -1383,12 +1208,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "smawk" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" - [[package]] name = "socket2" version = "0.5.7" @@ -1399,27 +1218,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "supports-color" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9829b314621dfc575df4e409e79f9d6a66a3bd707ab73f23cb4aa3a854ac854f" -dependencies = [ - "is_ci", -] - -[[package]] -name = "supports-hyperlinks" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee" - -[[package]] -name = "supports-unicode" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" - [[package]] name = "syn" version = "2.0.75" @@ -1464,36 +1262,6 @@ dependencies = [ "libc", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "terminal_size" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" -dependencies = [ - "rustix", - "windows-sys 0.48.0", -] - -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" -dependencies = [ - "smawk", - "unicode-linebreak", - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.63" @@ -1531,9 +1299,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -1577,7 +1345,6 @@ dependencies = [ "futures-core", "pin-project-lite", "tokio", - "tokio-util", ] [[package]] @@ -1622,9 +1389,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" dependencies = [ "async-stream", "async-trait", @@ -1640,7 +1407,7 @@ dependencies = [ "hyper-util", "percent-encoding", "pin-project", - "prost 0.13.1", + "prost 0.13.2", "socket2", "tokio", "tokio-stream", @@ -1656,9 +1423,9 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5563899ec5aa5f0ec48e37457461ffbbc184c9a0f413f715dacd154f46408a10" dependencies = [ - "prost 0.13.1", + "prost 0.13.2", "prost-types", - "tonic 0.12.1", + "tonic 0.12.2", ] [[package]] @@ -1742,12 +1509,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-linebreak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" - [[package]] name = "unicode-normalization" version = "0.1.23" @@ -1757,12 +1518,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-width" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" - [[package]] name = "url" version = "2.5.2" @@ -1866,15 +1621,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "winapi-util" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" -dependencies = [ - "windows-sys 0.59.0", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -1893,15 +1639,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-targets" version = "0.48.5" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 7ab97dd32b..6121c82c41 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -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", ] diff --git a/rust/bin/meta/Cargo.toml b/rust/bin/meta/Cargo.toml new file mode 100644 index 0000000000..abb129eabf --- /dev/null +++ b/rust/bin/meta/Cargo.toml @@ -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" diff --git a/rust/bin/meta/src/handler.rs b/rust/bin/meta/src/handler.rs new file mode 100644 index 0000000000..fc7e547286 --- /dev/null +++ b/rust/bin/meta/src/handler.rs @@ -0,0 +1,25 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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 { + +} + + + + diff --git a/rust/bin/meta/src/handler/meta.rs b/rust/bin/meta/src/handler/meta.rs new file mode 100644 index 0000000000..9133b5e514 --- /dev/null +++ b/rust/bin/meta/src/handler/meta.rs @@ -0,0 +1,40 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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, + ) -> std::result::Result, tonic::Status> { + todo!() + } + async fn set( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status> { + todo!() + } + + async fn delete( + &self, + request: tonic::Request, + ) -> std::result::Result, tonic::Status> { + todo!() + } +} \ No newline at end of file diff --git a/rust/bin/meta/src/main.rs b/rust/bin/meta/src/main.rs new file mode 100644 index 0000000000..df0c321fb3 --- /dev/null +++ b/rust/bin/meta/src/main.rs @@ -0,0 +1,30 @@ +// +// Copyright (C) 2019-2024 vdaas.org vald team +// +// 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> { + 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(()) +} \ No newline at end of file diff --git a/rust/libs/proto/Cargo.toml b/rust/libs/proto/Cargo.toml index 12a488941d..56505cf1bd 100644 --- a/rust/libs/proto/Cargo.toml +++ b/rust/libs/proto/Cargo.toml @@ -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" diff --git a/rust/libs/proto/src/lib.rs b/rust/libs/proto/src/lib.rs index b9b1d0bac0..7155b32bc7 100644 --- a/rust/libs/proto/src/lib.rs +++ b/rust/libs/proto/src/lib.rs @@ -36,3 +36,9 @@ pub mod core { include!("core.v1.tonic.rs"); } } + +pub mod meta { + pub mod v1 { + include!("meta.v1.tonic.rs"); + } +}